首页 > 解决方案 > 如何使用 Win32Com 处理 Inkscape?

问题描述

我已成功使用 win32com 与 MS Visio 进行交互。很棒的图书馆。现在我想对 Inkscape 做同样的事情,但似乎无法在网上找到任何足够的信息。

import win32com.client
from win32com.client import constants
app = win32com.client.Dispatch(Inkscape.Application
app.Visible = 1

返回

    ---------------------------------------------------------------------------
com_error                                 Traceback (most recent call last)
C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py in _GetGoodDispatch(IDispatch, clsctx)
     88                 try:
---> 89                         IDispatch = pythoncom.connect(IDispatch)
     90                 except pythoncom.ole_error:

com_error: (-2147221005, 'Ungültige Klassenzeichenfolge', None, None)

During handling of the above exception, another exception occurred:

com_error                                 Traceback (most recent call last)
<ipython-input-4-ce241241c43e> in <module>
----> 1 getVisio()

<ipython-input-3-266ab8177f92> in getVisio()
      2     ''' gets a handle on the visio application.
      3     sets global vApp'''
----> 4     vApp = win32com.client.Dispatch("Inkscape.Application")
      5     vApp.Visible =1
      6     return vApp

C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\__init__.py in Dispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, clsctx)
     93   """
     94   assert UnicodeToString is None, "this is deprecated and will go away"
---> 95   dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
     96   return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx)
     97 

C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py in _GetGoodDispatchAndUserName(IDispatch, userName, clsctx)
    112         else:
    113                 userName = str(userName)
--> 114         return (_GetGoodDispatch(IDispatch, clsctx), userName)
    115 
    116 def _GetDescInvokeType(entry, invoke_type):

C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py in _GetGoodDispatch(IDispatch, clsctx)
     89                         IDispatch = pythoncom.connect(IDispatch)
     90                 except pythoncom.ole_error:
---> 91                         IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
     92         else:
     93                 # may already be a wrapped class.

com_error: (-2147221005, 'Ungültige Klassenzeichenfolge', None, None)

我不明白错误消息告诉我什么。欢迎任何提示。提前致谢。

标签: pythonwin32cominkscape

解决方案


推荐阅读