So what I'm trying to do is to access the Microsoft Word API (which is written in VBA) from python with "pywin32" module. Specifically I need to iterate through the whole .docx file and find the location where a certain string shows up and add some text after it. I successfully fetched some paragraphs from the file with Document.Paragraphs.Items(index) and print them out, but when I try to compare it with my hard-coded string to see whether they matches or not, it always false, I did some type check to the paragraph I got from the .docx file then realized it is not a python string, that should be why it never matches with my string. Below is some code I wrote to show what is happening:
word = win32.gencache.EnsureDispatch('Word.Application')
word.Documents.Open('xxxxxxxxx.docx')
string = word.Documents(1).Paragraphs.Item(3)
print string
if string == "My Hard Coded String":
print "True"
else:
print "False"
So the above code snippet always gives me False even if the string that gets printed out at line 4 is exactly "My Hard Coded String", I'm reading the VBA documentation but there seems no any object or methods which has anything to do with converting the paragraph instance into python string (this might be a strange statement since VBA has nothing to do with python but...trying to summarize my question more clearly), any idea about how should I achieve this? Thanks in advance!
More Edit: Somebody has answered my question but I do not know where can I find all the objects/properties that Paragraph.Range has. I have been looking at MSDN and I don't think they lists any properties that belongs to "Range".