top of page

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:


  1. Set the Excel file path for the variable “%ExcelFilePath%



  2. Get the file name of the Excel file path using “Get File Path Part” action



  3. Under Variables produced, enable “The name of the source file” and change the variable to “%InputFileName%



  4. Set the name of the sheet you want to export in a variable and the PDF file path



  5. 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:


  1. While Excel is closed



  2. 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

bottom of page