[Tutor] Saving Excel file as HTML

Shitiz Bansal shitizb at yahoo.com
Sat Feb 14 06:59:00 EST 2004


hi,
I have been using python to Automate Excel using the Dispatch method in win32com module.
I have written a script to create and write an excel doc.
I want to save this document in HTML format.
 
I used the visual basic editor in excel macros to find out the desired syntax.
but unfortunately i am getting an error.
Can anybody help.
Also i would like to know if i can somehow set the width of individual columns in excel .Microsoft help  didnt help much.
 
here is a part of my script:
 
x=listdir('C:\\teams/'+j+'/teams')
    xlApp.Workbooks.Add()
    xlBook = xlApp.Workbooks(1)
    xlSheet = xlApp.Sheets(1)
    xlSheet.Cells(1,1).Value = 'TeamName'
    xlSheet.Cells(1,2).Value = 'Institute'
    xlSheet.Cells(1,3).Value = 'Team Members'
......
    xlBook.SaveAs(Filename='C:\\temp1\\'+j ,FileFormat='xlHtml')
    xlBook.Close()
Traceback (most recent call last):
  File "C:\Documents and Settings\Shitiz\Desktop\tryst_scripts\done1.py", line 38, in ?
    xlBook.SaveAs(Filename='C:\\temp1\\'+j ,FileFormat='xlHtml')
  File "<COMObject <unknown>>", line 2, in SaveAs
com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Excel', 'SaveAs method of Workbook class failed', 'C:\\Program Files\\Microsoft Office\\Office10\\1033\\xlmain10.chm', 0, -2146827284), None)
 


---------------------------------
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20040214/3d6d84af/attachment.html


More information about the Tutor mailing list