Hi
I have been looking at simple examples of controlling applications like excel and word using python. All seems well until I read in a word document with multiple lines. It then seems to pick out seemingly random sections of the document to display.
This is the class that is handling the opening etc of the document
class word:
def __init__(self, filename=None):
"""
@ Opens a word document specified by the user
"""
print "Initiating and opening..."+str(filename)
self.wdApp = win32com.client.Dispatch('Word.Application')
self.wdDoc = self.wdApp.Documents.Open(filename)
def save(self, newfilename=None):
""" Saves the open document with
a user defined new filename
"""
if newfilename:
self.filename = newfilename
self.wdDoc.SaveAs(newfilename)
else:
self.wdDoc.Save()
def close(self):
print "Preparing to close"
#self.wdDoc.Close()
self.wdDoc.Close()
self.wdApp.Quit()
#del self.wdApp
def show(self):
self.wdApp.Visible = 1
def hide(self):
self.wdApp.Visible = 0
def getFileContents(self):
print "Get file contents"
docString = self.wdApp.Documents[0].Content
return str(docString).decode('latin-1')
Dean Gardner
Test Engineer
Barco
Bonnington Bond, 2 Anderson Place, Edinburgh EH6 5NP, UK
Tel + 44 (0) 131 472 5731 Fax + 44 (0) 131 472 4799
www.barco.com
[EMAIL PROTECTED]
Unless indicated otherwise, the information contained in this message is privileged and confidential, and is intended only for the use of the addressee(s) named above and others who have been specifically authorized to receive it. If you are not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this message and/or attachments is strictly prohibited. The company accepts no liability for any damage caused by any virus transmitted by this email. Furthermore, the company does not warrant a proper and complete transmission of this information, nor does it accept liability for any delays. If you have received this message in error, please contact the sender and delete the message. Thank you.
- - - - - - - DISCLAIMER- - - - - - - -
Unless indicated otherwise, the information contained in this message is privileged and confidential, and is intended only for the use of the addressee(s) named above and others who have been specifically authorized to receive it. If you are not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this message and/or attachments is strictly prohibited. The company accepts no liability for any damage caused by any virus transmitted by this email. Furthermore, the company does not warrant a proper and complete transmission of this information, nor does it accept liability for any delays. If you have received this message in error, please contact the sender and delete the message. Thank you.
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
