I am trying to use Interop.Excell to save an Excel Workbook as a PDF file. I am using VS2008 and Office2007, and have downloaded and installed the SaveAsPDFandXPS.exe from Microsoft. This enabled me to save a Word document as a pdf using the following code: object frmt = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF; wrd.ActiveDocument.SaveAs(ref dest, ref frmt, ref unknown, ref unknown,... Pretty cool excpet for the whole Interop thing.
Anyway, I have been unsucsessful in finding a parallel in Interop.Excell for the Word.WdSaveFormat.wdFormatPDF. The Workbook.SaveAs takes a Interop.Excel.XlFileFormat, but there is no option for a pdf format. Has anyone done this or has experience in this area?
-
This question has been answered here:
You need to call the
Workbook.ExportAsFixedFormat
method:ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF FileName:=“sales.pdf” Quality:=xlQualityStandard DisplayFileAfterPublish:=True
This method should be preferred over using
SaveAs
because it also allows specifying all PDF / XPS options.Note: This method has been added to the Excel object model with Excel 2007 and requires the Save as PDF or XPS Add-in for 2007 Microsoft Office programs (or SP2) to be installed.
0 comments:
Post a Comment