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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SukumarMaddineni1
    New Member
    • Jun 2010
    • 2

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

    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.

    Code:
    workbook = MicrosoftExcel.Workbooks.Open(document.filePath, 0, False, 2)
    workbook.Application.AskToUpdateLinks = 0
    outputFileFolder = outputFolder+'\\'+str(ncount)
    outputFile = outputFileFolder+'\\'+str(ncount)+'.pdf'
    workbook.SaveAs(outputFile, 57)  # at this line error is coming


    Please help in this regards

    Thanks & regards
    Sukumar Maddineni
    Last edited by bvdet; Sep 10 '10, 01:48 PM. Reason: Add code tags
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    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 programmaticall y. You should be able to convert within Excel as well. Generally you can print to file and choose PDF format instead of postscript.

    Comment

    • papin
      New Member
      • Nov 2011
      • 7

      #3
      You should install a PDF printer driver (such as PDF Creator) and produce your PDF directly from Excel. This is so basic nowadays...

      Comment

      Working...