0

I am using win32 client to open a microsoft word document. I would like to convert word version to 2016 and I am encountering error

from win32com import client
import pythoncom
pythoncom.CoInitialize()
word = client.Dispatch("Word.Application")
word.Visible = True
doc = word.Documents.Open(r'C:\Users\<username>\Documents\<filepath>\test.docx')
doc.Convert()
doc.Save()
doc.Close()
word.Quit()

and I am having this error from word.Documents.open

    word = client.Dispatch("Word.Application")
  File "C:\Users\username\AppData\Local\Programs\Python\Python38-32\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File "C:\Users\username\AppData\Local\Programs\Python\Python38-32\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\Users\username\AppData\Local\Programs\Python\Python38-32\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147024703, 'OLE error 0x800700c1', None, None)```

How do I fix this?

Thank you!

1 Answer 1

0

I think that this error says Microsoft word document is not installed in your system.

Sign up to request clarification or add additional context in comments.

2 Comments

Hmm thats weird because it is installed
Then I think its a problem with version. refer:- stackoverflow.com/questions/18226090/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.