How to export a specific Excel sheet to PDF
๐ก Do you need to export a specific Excel sheet to PDF, regardless whether the Excel file is open or closed?
Problem Description
There are no actions available for exporting a specific Excel sheet to PDF in Power Automate Desktop.
Solution
The following flow provides a high level overview of the solution:
Set the Excel file path for the variable โ%ExcelFilePath%โ
Get the file name of the Excel file path using โGet File Path Partโ action
Under Variables produced, enable โThe name of the source fileโ and change the variable to โ%InputFileName%โ
Set the name of the sheet you want to export in a variable and the PDF file path
Export Excel sheet
While Excel is closed
Add โRun VBScriptโ action
Under Variable produced, enable โVBscriptOutputโ and โScriptErrorโ
Open the action and enter the code below:
Click Save
While Excel is Open
Add โLaunch Excelโ action, set the Document Path as โ%ExcelFilePath%โ and enable โMake instance visibleโ
Add โRun VBScriptโ action
Under Variable produced, enable โVBscriptOutputโ and โScriptErrorโ
Open the action and enter the code below:
Add โClose Excelโ action
The final output:
While Excel is closed
While Excel is open
Additional Information
Last updated on: 5 Dec 2024
Tested version(s): 2.50.00183.24303
Prerequisites: Excel
Dependencies: None
Known issues: None
References
Nil