Use visual basic 8.0
Dymo labelwriter 400
Installed Dymo labelwriter 400 Software Development Kit (SDK).

My problem is that there is a label is printed, but the mylabel. SetField are not included in the barcode label. The default values are printed.
The object name in the label are correct (OText1 and OText2).
The objects are OText1 and OText2 Variable text object.

Dim myDymo As Object
    Dim myLabel As Object
    Dim sPrinters As String
    Dim arrPrinters() As String
    Dim i As Long, i2 As Long, iStart As Long
    
    On Error Resume Next
    Set myDymo = CreateObject("Dymo.DymoAddIn")
    Set myLabel = CreateObject("Dymo.DymoLabels")
    If (myDymo Is Nothing) Or (myLabel Is Nothing) Then
        MsgBox "Unable to create OLE objects"
        Exit Sub
    End If
    
      sPrinters = myDymo.GetDymoPrinters()
    If sPrinters = "" Then
        Exit Sub
    Else
        i2 = 0
        iStart = 1
        For i = 1 To Len(sPrinters)
            If Mid(sPrinters, i, 1) = "|" Then
                i2 = i2 + 1
                ReDim Preserve arrPrinters(i2 + 1)
                arrPrinters(i2) = Mid(sPrinters, iStart, i - iStart)
                iStart = i + 1
            End If
        Next i
    End If
    
      sDefaultPrinter = Application.ActivePrinter
    With myDymo
         .SelectPrinter arrPrinters(0)
    End With
   
    'Open the label template
    myLabel = myDymo.Open("C:\SomeFolder\test.LWL")
    
 'Give text objects OText1 and OText2 on the label a value        myLabel
   myLabel .SetField( "OText1", "123456")
   myLabel.SetField ("OText2", "artcile x")
            
   'Print the label
   myDymo.print(1,fasle)
         
    'Make sure the default printer is selected again
    Application.ActivePrinter = sDefaultPrinter
    
    'Clean up
    Set myLabel = Nothing
    Set myDymo = Nothing

What am I forgetting the code or code which is wrong


Thanks in advance,

André

Andre:
If the code you showed was exactly what you have, and the barcode object (OText1) is not working, and OText2 is working, then correct the typos:

'Give text objects OText1 and OText2 on the label a value        myLabel   
[B]myLabel .SetField[/B]( "OText1", "123456")  'delete space before ".SetField"
myLabel.SetField ("OText2", "artcile x")    
'Print the label  
myDymo.print(1,[B]fasle[/B]) 'should be "false"

I hope this helps,
David

Andre:
If the code you showed was exactly what you have, and the barcode object (OText1) is not working, and OText2 is working, then correct the typos:

'Give text objects OText1 and OText2 on the label a value        myLabel   
[B]myLabel .SetField[/B]( "OText1", "123456")  'delete space before ".SetField"
myLabel.SetField ("OText2", "artcile x")    
'Print the label  
myDymo.print(1,[B]fasle[/B]) 'should be "false"

I hope this helps,
David

But in the actual code the code good!!!
myLabel.SetField ("OText1", "123456")
MyDymo.print(1,False)
But I still keep the same problem

So, does the code "myLabel.SetField ("OText2", "artcile x")" work to set the second object on the label? Please confirm.
Thanks.
David

This question has already been answered. Start a new discussion instead.