Step 1: Use the below macro in the Code section. Method 4: Print Active Sheet Using Macro ButtonĪnother variant of the macro can be used to save the Active Worksheet in PDF format and print it afterward. Read More: Print Range to PDF with VBA in Excel Open the PDF file then Follow Step 3 of Method 1 to print the file. Step 2: Afterward you click on the Macro Button, Excel saves the PDF file in the Workbook path. Don’t open the PDF file as the OpenAfterPublish command turned False. One of them directs the macro to save the PDF in the Workbook path.ģ – generate the Worksheet as a PDF file maintaining various properties. PrintRng.ExportAsFixedFormat Type:=xlTypePDF, _ġ – initiate the macro declaring the variables.Ģ – set the variables. Step 1: Type the below macro in the Code section. Also, we can add a Save command to just save the PDF in our desired destination. Now, if we change the OpenAfterPublish command from True to False, Excel won’t open the PDF file automatically. Method 3: Macro Button Save a Specific Range Using Macro Code to Print Repeat Step 3 of Method 1 to Save and Print the Worksheets in PDF format. Step 2:Use the Macro Button to run the macro. PrintPDF = Application.DefaultFilePath & "\" & _įilename:=PrintPDF, Quality:=xlQualityStandard, _ġ – introduce the variable and assign value to the variable.Ģ – the VBA Sheets.Select statement takes multiple sheets using the VBA Array function.ģ – set the Print Area to a specific range.Ĥ – assign the PDF file properties and load the file after conversion as the OpenAfterPublish command is set to True. Step 1: Paste the following Macro into the Visual Basic window. However, this macro can print multiple Worksheets just by inserting multiple Worksheet names in the macro. This macro variant is similar to Method 1. Method 2: Print Multiple Sheets Using Macro Button Read More: Excel VBA to Print As PDF and Save with Automatic File Name If you want to save the file go to File > Save As or Save. □ Remember Excel has not saved the PDF file yet. Click on the Print Icon as shown in the below image to print the Worksheet instantly. Step 3: Excel publishes the worksheet as PDF and converts the data into PDF format. Step 2: Click on the PRINT PDF Macro Button to run the macro. Also, the print area is supplied (i.e., B7:E17).ģ – export the file as PDF and ensure Print Properties as required. IncludeDocProperties:=True, IgnorePrintAreas:=False, _ġ – declare the variable and assign the File type as PDF.Ģ – the VBA Sheets.Select statement takes Sheet1 as about to print-worksheet. PrintFile = Application.DefaultFilePath & "\" & _Ī = "B7:E17"ĪctiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _įilename:=PrintFile, Quality:=xlQualityStandard, _ Step 1: Write the following macro in Microsoft Visual Basic window. Method 1: Use Macro Code to Print a Specific Worksheet in Excel Follow the latter section to know the methods in detail. The other one is- we can use the Macro Button to save the Worksheet as a PDF file and then use Print Command to print the Worksheet. The first one is- we can direct Print the Worksheet content with a simple click on the Macro Button. We can approach it in two different ways. Print to PDF through Macro Button in Excel: 5 Macro Alternatives Each time you want to print a Worksheet in PDF, just click on the Macro Button Excel will Save or Print the Worksheet or Worksheets in PDF. □ Excel brings up the Microsoft Visual Basic window and you see a similar depiction as shown in the image below.Īfter inserting a macro into this Microsoft Visual Basic window, you can simply run the macro using the Command Button. □ At last, to insert and assign a macro to this Command Button, Right-click on it. Edit the Caption or other Options according to your requirements. Select Properties from the Context Menu options. □ Immediately, Excel inserts a Command Button. □ Go to the Developer tab > Insert section > Click on Command Button (under ActiveX Controls). As Excel users typically have to print Worksheets in PDF, they can use a Macro Button to instantly Save or Print. Usually, users use the Keyboard Shortcuts key (i.e., F5) or Microsoft Visual Basic’s Run Toolbar > Run to execute a macro. Related Articles Macro Button & Its Insertion
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |