Dymo Labelwriter SDK Problem

Hi,
I’m new to Xojo and am having a problem trying to use the Dymo Labelwriter SDK (the high level COM interface). I am using a VBA sample as a guide and have the following (partial) code:

  Dim DymoAddIn As  OLEObject
  Dim DymoLabel As OLEObject
  Dim objParam As OLEParameter
  Dim openparam As Variant
  Dim setparams(1) As Variant
  Dim printparams(1) as Variant
  
  DymoAddIn = New OLEObject("Dymo.DymoAddIn")
  DymoLabel = New OLEObject("Dymo.DymoLabels")
  
  If DymoAddIn = Nil Or DymoLabel = Nil Then
    MsgBox("Unable to create OLE Objects")
  End
  
  Dim label As String = ConvertEncoding("John Doe" + EndOfLine + _
  "123 Main Street" + EndOfLine + _
  "Anytown, NJ 00000", Encodings.UTF16)
  
  Dim f As String = ConvertEncoding("E:\\Users\\dgh\\Documents\\DYMO Label v.8 SDK" + _
  "\\DLS SDK\\Samples\\High Level COM\\MS Access\\Address (30252, 30320, 30572).LWL", _
  Encodings.UTF16)
  objParam = New OLEParameter
  objParam.Type = OLEParameter.ParamTypeString
  objParam.Position = 1
  objParam.Value =  f
  openparam = objParam
  DymoAddIn.Invoke("Open", openparam)

I am getting a runtime TypeMismatchException on the last line. The SDK documentation for the Open method is:

Open(const FileName: WideString)

I have tried without using the OLEParameter and just setting the openparam variant to the f string with the same runtime error. I have also tried without changing the string encoding to UTF16 - same runtime error.

Does anyone have any experience with the Dymo SDK or any suggestions on what I should try next?

I am on Windows 8.1 Pro.

Thanks for any help.

Dennis

We’ve printed to a Dymo printer before. You don’t need to use the SDK, you can treat it like a normal printer using the graphics object.

1 Like

The Dymo SDK is an interface to the Dymo Label software. The software has some features such as automatically generating and printing the IMDB postal barcode for an “address” field placed on the label design. It can also auto fit the address to the label. For my present needs, no need to re-invent the wheel with Xojo code.

I continued to experiment and discovered that the Invoke method was the problem. The following test code worked perfectly:

  Dim DymoAddIn As  OLEObject
  Dim DymoLabel As OLEObject
  
  DymoAddIn = New OLEObject("Dymo.DymoAddIn")
  DymoLabel = New OLEObject("Dymo.DymoLabels")
  
  If DymoAddIn = Nil Or DymoLabel = Nil Then
    MsgBox("Unable to create OLE Objects")
  End
  
  Dim f As String = "E:\\Users\\dgh\\Documents\\DYMO Label v.8 SDK" + _
  "\\DLS SDK\\Samples\\High Level COM\\MS Access\\Address (30252, 30320, 30572).LWL"
  DymoAddIn.Open(f)
  
  Dim label As String = "John Doe" + EndOfLine + _
  "123 Main Street" + EndOfLine + _
  "Anytown, NJ 00000"
  DymoLabel.SetField("Address", label)
  
  DymoAddIn.StartPrintJob
  DymoAddIn.Print(1, True)
  DymoAddIn.EndPrintJob

Dennis

1 Like