I am trying to use win32com(pywin32) and Microsoft Word's Object Model to Compare two Word Documents(Automating the task of Comparing two documents in Microsoft word under Review->Compare). Following is the code I have written for this:
import win32com.client
Application=win32com.client.gencache.EnsureDispatch("Word.Application")
Document=Application.Documents.Add()
Application.CompareDocuments("Original.docx","Revised.docx")
But I am getting the following error:
Traceback (most recent call lastFile "<pyshell#9>", line 1, in <module>
Application.CompareDocuments("Original.docx","Revised.docx")
File "C:\Python36\lib\site-packages\win32com\gen_py\00020905-0000-0000-C000-000000000046x0x8x6\_Application.py", line 79, in CompareDocuments
, CompareFields, CompareComments, CompareMoves, RevisedAuthor, IgnoreAllComparisonWarnings
File "C:\Python36\lib\site-packages\win32com\client\__init__.py", line 466, in _ApplyTypes_
return self._get_good_object_(self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args),user, resultCLSID)
TypeError: The Python instance can not be converted to a COM object
I am not able to understand why this error is being thrown. I really want to resolve this issue.Please help.
Thanks in Advance