[python-win32] Excel
John Machin
sjmachin at lexicon.net
Tue Jan 10 20:09:11 CET 2006
Stefan Elwesthal wrote:
> Hi all!
>
> I have to ask, cause two days later I'm starting to get annoyed ;-)
>
> How could I use PythonCOM and save my re-worked Excel file as an xlCSV file? All I get is
> "SaveAs method in Worksheet class failed".
>
> Is something wrong with this line?
Yes. Two things.
> sh.SaveAs("C:\file.csv", FileFormat='xlCSV')
(1) Elementary precaution for working with file paths in Windows using
Python is to use eithereither raw strings or slashes:
sh.SaveAs(r"C:\file.csv", FileFormat='xlCSV')
or
sh.SaveAs("C:/file.csv", FileFormat='xlCSV')
By so doing you don't run the risk of the first letter of a "word" being
interpreted as a control character (form feed in your case).
(2) The FileFormat argument is an int, not a string
More information about the Python-win32
mailing list