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. To print this range we are using the ExportAsFixedFormat method. 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. It processed these 3 Excel files fairly quick, less than 1 minute.Related Articles Print Range to PDF Using Excel VBA: 5 Cases This workflow works fine on your workstation, but it will have difficutlies if deployed to the Alteryx Server because we hardcoded the Excel files it process, the workflow may need to be converted to an Analytic Application. We are set, now we run the workflow, it generates 3 PDF files, each one located at the folder where the Excel file is found. Warning: If the workflow is running local on your workstation (laptop or desktop), you can enter any folder and it will work while if you deploy this workflow to the server, the environment to select the files is different, beside, the list of files is "hard coded" into the workflow, so my advice to deploy to the Alteryx Server is to convert this workflow to an Analytic Application. This step is simple, just add the file or files to the input tool.Update the workflow's Text Input with the file or files to process: I am not sure, but the Workflow-macro-vbs will print whatever is defined in the "Print Area" so if your Excel file has many sheets, it will print whatever is defined as Print Area (I haven't test this).We followed Maria's directions to set the "Print Area" on these two sheets.The third Excel file is: "SO FC data sample.xlsx" also located on my D:\Temp\2023-07-July, with 3 sheets: "Sheet1", "Sheet2" and "Sheet3", in this case "Sheet3" is empty, nothing to do with it.Let's allow Maria on this video to explains: How to Set the Print Area in Excel (Step by Step) (Great video by the way) This Sheet contains 17 record, We need to define its print area in Excel. " Sheet2" and " Sheet3" are empty, so nothing to do with them.The second Excel file is: " B2B TackMyOrder Testing.xlsx", this file has 3 worksheets: " Sheet1", " Sheet2" and " Sheet3".The first Excel file is the Sample_File_1.xlsx already shared, nothing to do here.The first file, "Sample_File_1.xlsx" is on the folder where the workflow is located, while the second and third files are at the folder: "D:\temp\2023-07-July".You or your user should define the Print Area in the Excel file, by example I am generating the PDF file for 3 Excel files.Update the workflow's Text Input with the file or files to process.There are two steps you or your users should do: Hi you are getting exposure to new knowledge,
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |