lmielke
lmielke

Reputation: 125

DYMO label writer 'Invalid class string'

I am trying to get my DYMO LabelWrite 450 Duo to print a label.

However, I am having trouble making the script do anyting. When I run the script below:


    from win32com.client import Dispatch

    labelCom = Dispatch('Dymo.DymoAddIn')
    labelText = Dispatch('Dymo.DymoLabels')
    print(f"labelCom: {labelCom}")

I get the following error message:


    Traceback (most recent call last):
      File "C:\Users\lars\.virtualenvs\Labels-MxmV_EZi\lib\site-packages\win32com\client\dynamic.py", line 84, in _GetGoodDispatch
        IDispatch = pythoncom.connect(IDispatch)
    pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "main.py", line 4, in <module>
        labelCom = Dispatch('Dymo.DymoAddIn')
      File "C:\Users\lars\.virtualenvs\Labels-MxmV_EZi\lib\site-packages\win32com\client\__init__.py", line 118, in Dispatch
        dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch, userName, clsctx)
      File "C:\Users\lars\.virtualenvs\Labels-MxmV_EZi\lib\site-packages\win32com\client\dynamic.py", line 104, in _GetGoodDispatchAndUserName
        return (_GetGoodDispatch(IDispatch, clsctx), userName)
      File "C:\Users\lars\.virtualenvs\Labels-MxmV_EZi\lib\site-packages\win32com\client\dynamic.py", line 87, in _GetGoodDispatch
        IDispatch, None, clsctx, pythoncom.IID_IDispatch
    pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)

I am using:

Pipfile:

  ...
  [packages]
  pywin32 = "*"
  [requires]
  python_version = "3.7"
  ...

I tried the following:

I re-installed both DCDSetup and SDK with no effect. I downgraded from python 3.11 to 3.7, no effect. I tried to run python as Admin, no effect. I tried to find the dymo com name using regedit, but couldnt find it. None worked.

NOTE: When I use the UI, the printer works just fine. Has anyone a idea, what I am doing wrong?

Upvotes: 0

Views: 181

Answers (0)

Related Questions