[Tutor] Automating MSWord (error if run from command line; no
error if ru n within PythonWin)
Ezequiel, Justin
j.ezequiel@spitech.com
Fri Mar 21 20:38:01 2003
Thanks lots Danny!
##This did the trick:
sFile = os.path.abspath(sFile)
What I am now wondering is why the following did not work
without that line when the files are all in the same folder
X:\>python forPost.py omc00055.doc
note that the isfile() check returned true before the call to abspath()
##final code:
def process(sFile):
if os.path.isfile(sFile):
sFile = os.path.abspath(sFile)
print "Processing", sFile
sRTFFile = GetRTFFile(sFile)
print "Saving as RTF..."
SaveFile(sFile, sRTFFile, 6)
if processRTF(sRTFFile):
print "Saving as DOC..."
SaveFile(sRTFFile, sFile, 0)
print "Made changes to", sFile
else:
print "No changes made to", sFile
os.remove(sRTFFile)
else:
print "Cannot find", sFile