Skip to main content

Notifications

Community site session details

Community site session details

Session Id : P3nD/YYS4Up/cUqOLLEy8B
Power Automate - Building Flows
Answered

How to run office scripts on dynamically created excel file?

Like (0) ShareShare
ReportReport
Posted on 29 Sep 2023 05:01:30 by

Hi Folks,

 

I'm trying to run a script of a excel file using power automate. The excel file was created from a template in a previous step in same flow. So the scripts will not be listed in the drop down. I get the below error if I try to give the script name ( I also need to pass parameters). The "full path" is from create file action above. 

 

rbn_nue_0-1695963605125.png

 

 

I'm aware of the Run scripts from sharepoint library, which is working fine. But since it's still in preview mode, I was wondering if it's possible to use the above action itself. 

 

Any insights?

 

Thanks

  • Suggested answer
    CU30041023-0 Profile Picture
    2 on 30 Apr 2025 at 10:29:16
    How to run office scripts on dynamically created excel file?
    FYI: for people searching a specific awnser:
     
    You can run "Run script from SharePoint library" using dynamic Excel files by using the "DriveItemId" of the file:
     
    1. get the properties of the excel file using the SharePoint action "Get file properties"
    2. in the action "Run script from SharePoint library" use the "DriveItemId" property for the argument "Workbook":
    outputs('Get_file_propeties')?['body/{DriveItemId}']
     
  • MichelleRanMSFT Profile Picture
    Microsoft Employee on 02 Oct 2023 at 16:33:34
    Re: How to run office scripts on dynamically created excel file?

    Glad I could help! We expect the action to exit preview within the next few weeks.

  • rbn_nue Profile Picture
    on 02 Oct 2023 at 13:50:57
    Re: How to run office scripts on dynamically created excel file?

    hi @MichelleRanMSFT 

     

    Thanks for the update. That cleared all the questions I had. @FLMike  - I was referring to the third point from @MichelleRanMSFT. Appreciate your inputs. 

     

    @MichelleRanMSFT  - if possible, can you provide the road map or the time line on when the "Run script from SharePoint library" action will exit the preview mode (link to doc should be good, if one exists?

     

    Thanks for the suggestions!

  • Verified answer
    MichelleRanMSFT Profile Picture
    Microsoft Employee on 29 Sep 2023 at 19:27:18
    Re: How to run office scripts on dynamically created excel file?

    Hi @rbn_nue, chiming in on a few points here:

    • The "Run script from SharePoint library" action should be exiting preview soon, so if that's working for you, feel free to continue using it.
    • Generally, entering a script name as a custom value won't work - you'd need to select a script from the dropdown or provide a file id.
    • Additionally, the "Run script" action only works for scripts that are stored in the current user's OneDrive. Scripts shared within a workbook by another user won't be available. I'd suggest that you use the "Run script from SharePoint library" action instead.

    Let me know if that helps, or if you have any other questions!

  • Michael E. Gernaey Profile Picture
    41,516 Super User 2025 Season 1 on 29 Sep 2023 at 13:28:37
    Re: How to run office scripts on dynamically created excel file?

    Hello,

     

    Apologies, I don't quite understand.

     

    Are you saying that I was correct, that the Copy didn't have the script? And now you are saying you have a second "variation" of the same issue? I see the second photo, shows no script, but I am not sure if that is you doing the manual test I gave you, on the second scenario you are referring too or the first?

     


    Cheers
    If you like my answer, please Mark it as Resolved, and give it a thumbs up, so it can help others
    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

  • rbn_nue Profile Picture
    on 29 Sep 2023 at 11:12:50
    Re: How to run office scripts on dynamically created excel file?

    @FLMike 

     

    I just saw another scenario. I shared the script to the workbook, which indicated that anyone having access to this excel will have access to script. I was able to confirm this by opening the same excel which I stored in SharePoint (same tenant) using a different account (service account) and I saw below scripts associated with the workbook:

     

    rbn_nue_0-1695985843064.png

     

     

    I can see it's in the other account one drive. 

     

    Now using the same service account which has access to these scripts via excel, I tried to create a flow and added run script action, pointing to the same file and I don't see any scripts!!

     

    rbn_nue_1-1695985941807.png

     

    Could you please let me know if I'm missing something?

     

    Thanks

  • rbn_nue Profile Picture
    on 29 Sep 2023 at 06:31:50
    Re: How to run office scripts on dynamically created excel file?

    Hi @FLMike 

     

    You were right, It seems the script is not available in the excel as per the new flow. The script is stored in my onedrive (Checked the excel from local machine), whereas the excel template will be stored in SharePoint of another tenant. Is there anyway I can attach the script to excel, or can the excel refer script SPO library?

     

    Thanks 

  • Verified answer
    Michael E. Gernaey Profile Picture
    41,516 Super User 2025 Season 1 on 29 Sep 2023 at 06:12:58
    Re: How to run office scripts on dynamically created excel file?

    Hi,

     

    Just to verify, can you please go look at one of the files you want to do this too and validate the script is there.

    Then please create another flow, that does nothing else (Make it manual), then add a Run Script. 

     

    • See if the script is visible (remember this is one of the dynamically generated files from the template)
    • Set if you can run it works.
    • Lasty, can you verify , from a run, what the output is from Create File and the input of the Run Script. Literally so you can see the value of full path to make sure its actually pointing at the file.

     

    Also, for the details for Script, just to verify, you clicked Enter custom value and then typed it in?

     

    If so, it should work, to the best of my knowledge, which makes me think its an issue with the file and or the script in the file. If you can do the first 2 steps above that would be super helpful.


    Cheers
    If you like my answer, please Mark it as Resolved, and give it a thumbs up, so it can help others
    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,731 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,075 Most Valuable Professional

Leaderboard