[Tutor] Automating MSWord (error if run from command line; no error if ru n within PythonWin)

Bob Gailer bgailer@alum.rpi.edu
Fri Mar 21 10:16:01 2003


--=======22BE3BCE=======
Content-Type: text/plain; x-avg-checked=avg-ok-1A195FEA; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 8bit

At 02:06 PM 3/21/2003 +0800, Ezequiel, Justin wrote:

>I am getting the following message when running my program from the 
>command line (X:\>python DelStyles.py jd002790.doc).
>The program runs file under PythonWin (Ctrl-R)!
>I am using Python 2.2.2 on WinXP Service Pack 1.
>I've installed py2exe-0.3.3.win32-py2.2.exe and win32all-152.exe in that 
>order, if it matters.
>Ultimately, I would like to package my program using py2exe.
>I can attach the entire program if you like (104 lines).
>Thanks in advance.
>
>Processing jd002790.doc
>Saving as RTF...
>Traceback (most recent call last):
>   File "DelStyles.py", line 101, in ?
>     process(sys.argv[1])
>   File "DelStyles.py", line 90, in process
>     SaveFile(sFile, sRTFFile, 6)
>   File "DelStyles.py", line 82, in SaveFile
>     doc = win32com.client.GetObject(sOldFile)
>   File "D:\PYTHON22\lib\site-packages\win32com\client\__init__.py", line 
> 73, in
>GetObject
>     return Moniker(Pathname, clsctx)
>   File "D:\PYTHON22\lib\site-packages\win32com\client\__init__.py", line 
> 89, in
>Moniker
>     dispatch = moniker.BindToObject(bindCtx, None, pythoncom.IID_IDispatch)
>pywintypes.com_error: (-2147287038, 'STG_E_FILENOTFOUND', None, None)

 >>> doc = win32com.client.GetObject(sOldFile)  works for me if I provide 
the entire path name. Otherwise I get a VARIETY of errors depending on the 
value.

Other interesting things happen with doc: the document opened by GetObject 
is not visible (Word 2000).
 >>> doc.application.visible
1
 >>> doc.application.visible=1
After this the document IS visible! but its name is NOT in the title bar!

Bob Gailer
PLEASE NOTE NEW EMAIL ADDRESS bgailer@alum.rpi.edu
303 442 2625

--=======22BE3BCE=======
Content-Type: text/plain; charset=us-ascii; x-avg=cert; x-avg-checked=avg-ok-1A195FEA
Content-Disposition: inline


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.463 / Virus Database: 262 - Release Date: 3/17/2003

--=======22BE3BCE=======--