Home > front end >  Pywintypes.com _error: (- 2147221008, 'not call CoInitialize.', None, None)
Pywintypes.com _error: (- 2147221008, 'not call CoInitialize.', None, None)

Time:04-16

I met a problem: pywintypes.com _error: (- 2147221008, 'has yet to call CoInitialize,, None, None)
I through an online search, you need to call pythoncom. CoInitialize () function, but after I wrote up shows CoInitialze function is undefined, excuse me is there a great god help me answer the
The import OS
The from win32com import client
The import pythoncom
Def doc2docx (path) :
Pythoncom. CoInitialize ()
Word=client. Dispatch (' word. Application ')
Doc=word. The Documents. The Open (path) # target path of files
Newname=OS. Path. Splitext (path) [0] + ". Docx "
Doc. SaveAs (newname, # 16) into the path of files
Doc. The Close ()
Word. The Quit ()
Return newname