Where is Word?

Tim Golden tim.golden at viacom-outdoor.co.uk
Tue Jun 14 05:52:48 EDT 2005


[Guy Lateur]
| I need a way to get the path where MS Word/Office has been 
| installed. I need 
| to start Word from a script (see earlier post), but it 
| doesn't work if I 
| don't know its path. So "os.system("winword.exe %s" % 
| fileName)" doesn't 
| always work; I need to say "os.system("C:\Program Files\Microsoft 
| Office\Office10\winword.exe %s" % fileName)".

While this doesn't answer the question you're asking, I
believe it does solve the problem you're facing. Relying
on the fact that the Microsoft Office products will
have associated themselves as the default (Open) action
with files of the appropriate extensions, you can use
os.startfile:

<code>
import os

os.startfile ("c:/temp/blah.doc")
</code>

HTH
TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________



More information about the Python-list mailing list