Hi,
I have to substitute some words in MS-Word.
These few line works fine from command line, but they don't work after
packaged in a executable file with pyinstaller. It simply select the
word "DATA_DOC" without translate in "NEW_DATE"; the Execute return
True, and there are no errors.
import win32com.client, pythoncom, time
import pythoncom
myWord = win32com.client.DispatchEx('Word.Application')
myWord.Visible=True
myDoc = myWord.Documents.Open('c:/aa.doc')
myDoc.Application.Selection.Find.ClearFormatting()
myDoc.Application.Selection.Find.Text = 'DATA_DOC'
myDoc.Application.Selection.Find.Replacement.ClearFormatting()
myDoc.Application.Selection.Find.Replacement.Text = 'NEW_DATE'
print myDoc.Application.Selection.Find.Execute(Replace=2) # return True
in all cases (command line && executable)
I'm using pyinstaller from trunk with python2.6 on WinXp and MS-Office 2000.
Note that:
- cxfreeze and py2exe doesn't work at all in the same environment
- I'd like to try with python 3.1 but pyinstaller doesn't work on it
- In order to let it work with python 2.5 I have to use '''
win32com.client.gencache.EnsureDispatch('Word.Application') ''', but
pyinstaller doesn't work with it. So I have to use '''
win32com.client.DispatchEx('Word.Application',clsctx=pythoncom.CLSCTX_LOCAL_SERVER)
''' : the executable run, but it doesn't substitute the word.
Thanks
Alessandro
--
You received this message because you are subscribed to the Google Groups
"PyInstaller" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pyinstaller?hl=en.