Edit: I have a user control with embedded excel sheet and gridviews ( WinForm). I have a form which has that user control. I have a print button on top and I want to convert the whole form into printable format. Any suggestion on how to move ahead?
-
Printing an Excel document can be done using 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 to be installed.
See this related question: What is the FileType number for PDF in Excel 2007 that is needed to save a file as PDF through the API?
-
For versions earlier than 2007 you can embed/install a PDF printer and use the
PrintOut
method, specifyingActivePrinter
as required.
0 comments:
Post a Comment