

"C:\PDF\Export.pdf" is the path and name of your saving PDF file.Ħ. Note: In the code, CommandButton1 is the Command Button name you will use to save active sheet as PDF file.


VBA code: Command Button to save active worksheet as PDF Private Sub CommandButton1_Click()ĪctiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _ In the opening Microsoft Visual Basic for Applications window, please replace the original code in the Code window with the following VBA code. Right click the Command Button again, and then click View Code from the right-clicking menu.ĥ. You can see the displayed text of the Command Button is changed as below screenshot shown.Ĥ. In the Properties dialog box, enter the displayed text of the Command Button into the Caption box under the Categorized tab, and then close the dialog box. Then draw a Command Button in to the worksheet you need to add new rows, right click the Command Button and click Properties from the right-clicking menu.ģ. Please insert a Command Button by clicking Developer > Insert > Command Button (ActiveX Control). Here I create this folder in my local disc (C:).Ģ. Firstly, you need to create a folder named PDF for saving your new converted PDF file. You can run the following VBA code to save an active worksheet as PDF file by clicking on a Command Button. Use Command Button to save active worksheet as PDF file with VBA codeĮasily save active or each worksheet as individual PDF file with Kutools for Excel

And if you also want to save a range or each worksheet in active workbook as individual PDF file, this article can also help you. In this article, you can learn how to save active worksheet as PDF file with VBA code through a Command Button. While working in Microsoft Excel, you may face the problem of saving active worksheet as PDF file. How to use Command Button to save active worksheet as PDF file in Excel?
