By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,932 Members | 1,944 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,932 IT Pros & Developers. It's quick & easy.

Excel(xlsm) to PDF conversion failing,error "Save as method of Wroksheet class failed

P: 2
Hi,

I have one xlsm document , Using python I tried to convert that
document to PDF,

but COM raising pywintypes error "Save as method of Wroksheet class
failed".

Below is my code.

Expand|Select|Wrap|Line Numbers
  1. workbook = MicrosoftExcel.Workbooks.Open(document.filePath, 0, False, 2)
  2. workbook.Application.AskToUpdateLinks = 0
  3. outputFileFolder = outputFolder+'\\'+str(ncount)
  4. outputFile = outputFileFolder+'\\'+str(ncount)+'.pdf'
  5. workbook.SaveAs(outputFile, 57)  # at this line error is coming


Please help in this regards

Thanks & regards
Sukumar Maddineni
Sep 10 '10 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 621
You will likely have to convert the xls to text and use PyPdf or ReportLab to format as a pdf file if you want to do it programmatically. You should be able to convert within Excel as well. Generally you can print to file and choose PDF format instead of postscript.
Sep 14 '10 #2

P: 7
You should install a PDF printer driver (such as PDF Creator) and produce your PDF directly from Excel. This is so basic nowadays...
Nov 14 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.