2
I need help to resolve a syntax error in Visual basic of Excel, the command is as follows:
Application.ScreenUpdating = False
Dim wsh As Worksheet
Set wsh = Excel.ActiveSheet
Dim data As String
Dim r As Long 'The row index
r = 1
Do
data = wsh.Cells(r, 1) 'A1, A2, A3...
If Len(data) = 0 Then Exit Sub 'The code stops at the first empty cell
Dim rng As Range
Set rng = wsh.Cells(r, 2) 'Placing barcodes into B1, B2, B3...
Dim shp As Shape
Set shp = wsh.Shapes.AddOLEObject("STROKESCRIBE.StrokeScribeCtrl.1")
shp.LockAspectRatio = msoFalse
shp.Width = rng.Width
shp.Height = rng.Height
shp.Left = rng.Left
shp.Top = rng.Top
Dim barcode As StrokeScribe
Set barcode = shp.OLEFormat.Object.Object
barcode.Alphabet = QRCODE
barcode.Text = data
If barcode.Error Then
MsgBox barcode.ErrorDescription
Exit Do
End If
r = r + 1
Loop
Application.ScreenUpdating = True
How to find and modify existing barcode objects
Dim sh As Shape
Dim ss As StrokeScribe
Dim wsh As Worksheet
Set wsh = Excel.ActiveSheet
For Each sh In wsh.Shapes
If sh.Type = msoOLEControlObject And sh.OLEFormat.progID = "STROKESCRIBE.StrokeScribeCtrl.1" Then
Set ss = sh.OLEFormat.Object.Object
ss.Alphabet = DATAMATRIX
ss.Text = "1234ABCD"
End If
Next
What error occurs?
– user28595
Use the option to snippet and paste the code into it. It looks better to check.
– StillBuggin