How to get a “Print PDF” Button in Excel?

One of the features in Excel is the ability to convert Excel files to PDF format. In this article we explain how to create a button in the excel worksheet, which when clicked generates a PDF file of that sheet.

Let us take the picture below as example to take a PDF and save it in current folder.

Below are the steps to get a button, which converts the excel file to a PDF file:

Select Developer, select Insert from Control group and select Button from Form Controls.

Drag the control on the spreadsheet, a window appears.
Enter the name of the macro in the tab provided for Macro name and click OK.

To edit the name of the button, Right click on the button and select Edit Text.

Right click on the button and select Assign Macro.


Select the Macro name and select New.


A Microsoft Visual Basic window appears.


Enter the below code in the application where the arrow is pointed, under ‘Sub CreatePDF()’.

Sub CreatePDF()

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _

“Generate Report.pdf”, Quality:=xlQualityStandard, _

IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= False

End Sub

Close the Microsoft Visual Basic application, now just click on the CreatePDF button. That’s all a PDF will be generated and saved in the same folder.
If we want to change the name of the PDF, we can change it in the code. For example in the second line we have “Generate Report.pdf”, change it to “Create Report.pdf”.

 

————————————————————————————————————–

Vani is a Business Associate with p2w2, a Spreadsheet Solutions company. p2w2 has expertise in Excel ModelingExcel DashboardsProfitability Analysis,  Excel Invoicesand Excel Bid sheets. You can contact us by email: cs [at] p2w2.com or call us at 305.600.0950.

 

[Bloglines] [del.icio.us] [Digg] [diigo] [Facebook] [Furl] [Google] [kirtsy] [Ma.gnolia] [MySpace] [Propeller] [Reddit] [Simpy] [Sphinn] [StumbleUpon] [Technorati] [Windows Live] [Yahoo!]

[Post to Twitter]  [Post to StumbleUpon] 



No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment