I have a script that formats the data from a table to JSON. My Excel document has many sheets all with one table in each sheet. I am trying to pass in an input parameter (of type string) for the name of the sheet so that when I run the script I am able to specify the sheet that will convert the data. I currently have a default parameter "Sheet1." I don't know where I can specify the parameter when I run the script.
Format Table Data Code Snippet
I know I can Just copy the script for as many sheets I have in my Excel document and hard-code it so that each script formats the data in one sheet, but for obvious reasons, I don't want to do that.
At the time of writing, there are only two ways to pass extra arguments to an office script:
Use Power Automate (Option 1)
To pass an argument via Power Automate (option 1), which will be assigned to
sheetNamein your example office script, follow these steps:Create a new flow in Power Automate, or edit an existing one.
Add a 'run script' action
Enter the path to your saved Excel file into the
Filefield.Choose the relevant script from the
Scriptdrop down menu.After you choose your script, new fields that correspond to the script's parameters will appear in the action menu.
Enter your desired value for each field. You can type in static values, or use the features of Power Automate to supply dynamic values.