![]() Then, you will get the boolean result in cell F4.īesides, we will have our printed range PDF file in our desired location as a result of this function. Here, range_to_pdf is our created function and B3:E13 is the range to print it as PDF. ➤ Type the following formula in the first cell of the Print column. ![]() IgnorePrintAreas:=False for using the print areas, and openafterpublish:=True to open the file after creation is used.Īfter saving the code, return to the main sheet. Then, we have put 0 as the Type for printing this range as PDF and as a Filename, we have declared the path and set the file name PDF.įurthermore, the properties Quality:=0 for standard quality, and IncludeDocProperties:=False for ignoring the document properties. Here, we have declared the function range_to_pdf as Boolean and the function takes an input defined_rng as Range.įor printing this input range, we are using the ExportAsFixedFormat method. Function range_to_pdf(defined_rng As Range) As Boolean Here, we will create a function with the help of a VBA code, using this function we will select the range to print this range as PDF and this function will give us a boolean value in the Print column. Read More: Excel VBA to Print As PDF and Save with Automatic File NameĬase-3: Using Function to Print Range to PDF When you will open the printed file named PDF then you will see the following range in PDF format. ➤ Select the range which you want to print and press OK in the Input Box.įinally, we are having the printed PDF file in our defined location. IgnorePrintAreas:=False for using the print areas, and openafterpublish:=True to open the file after creation. In addition to this, we are using the further properties Quality:=0 for standard quality, and IncludeDocProperties:=False for ignoring the document properties. Then, we have put 0 as the Type for printing this range as PDF and as a Filename, we have declared the path and set the file name PDF. To print this range we are using the ExportAsFixedFormat method. ![]() Here, we have declared defined_rng as Range and then set it with the range which we will select after the appearance of the Input Box, and for this Input Box, we are using the InputBox method. "Choose the Specific Range", Title:="Microsoft Excel", Type:=8)ĭefined_rng.ExportAsFixedFormat Type:=0, _įilename:="C:\Users\Mima\Downloads\" & "PDF", _ Set defined_rng = Application.InputBox(Prompt:= _ In this section, we will select our desired range after running the code instead of predefining the range in the code for printing that range as a PDF. Read More: Excel VBA: ExportAsFixedFormat PDF with Fit to PageĬase-2: Using InputBox Method to Print Range to PDF with Excel VBA Then, you will have the PDF file in your defined location for saving this file.Īfter opening this file, we will have the following range as PDF. Moreover, the further properties Quality:=0 for standard quality, IncludeDocProperties:=False for ignoring the document properties, IgnorePrintAreas:=False for using the print areas, and finally to open the file after creation openafterpublish:=True is used. Then, we have put 0 as the Type for printing this range as PDF and as a Filename, we have declared the path with the name (value from cell F3) of this pdf. Here, we have declared the range B3:F13 of the active sheet to save as a PDF. Quality:=0, IncludeDocProperties:=False, IgnorePrintAreas:=False, _ ➤ Write the following code Sub range_to_pdf_1()ĪctiveSheet.Range("B3:F13").ExportAsFixedFormat Type:=0, _įilename:="C:\Users\Mima\Downloads\" & ActiveSheet.Range("F3").Value, _ Then, the Visual Basic Editor will open up. ➤ Go to the Developer Tab > Visual Basic Option. Here, we will print the following data range by declaring this range, and then we will save the PDF named after the value in cell F3. We have used Microsoft Excel 365 version here, you can use any other versions according to your convenience.Ĭase-1: Declaring a Range to Print Range to PDF with a Cell Value as PDF Name Throughout this article, we will print this data range with different VBA codes easily. Here, we have the following dataset containing the sales records of different products of a company. Related Articles Print Range to PDF Using Excel VBA: 5 Cases
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |