web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Perform actions on a s...
Power Automate
Unanswered

Perform actions on a specific workbook selected from a file.

(0) ShareShare
ReportReport
Posted on by

Greetings!

 

My situation is below which I have simplified because I have been able to design a flow that accomplishes most of what I want. I'm trying to simplify it.

 

I have 7 pre-built Excel workbooks stored in the same folder. Every month on the same day, I do the same exact five steps (see below) on all 7 workbooks.

 

The process would look like this:

Step 1) Open folder

Step 2) Open Excel workbook #1

Step 3) Refresh entire Excel workbook #1

Step 4) Print to PDF tabs 1 to 10, and tab 15 and 20.

Step 5) Close Excel workbook #1

Repeat Steps 1 to 5 (exactly as above) for Excel workbook #2, Excel workbook #3, Excel workbook #4, Excel workbook #5, Excel workbook #6 Excel workbook #7.

 

I have been able to build my flow so that it opens to any workbook I want and execute steps 1 through 5 above. My flow is very messy though because it consists of several subflows. Each sublfow uses the same "If then" and "Else if then" conditions to execute the same five steps.

 

I started with building 7 separate flows for each workbook and then I combined them all into one flow via the "If then" and "Else if then" conditions.

 

My question:

Since I have combined all 7 flows into 1, is there a way to tell my flow once from the beginning "Hey execute steps 1 through 5 for me regardless of if I open workbook #2 or workbook #6"?

 

Put another way: "If I chose workbook #1 OR workbook #3 OR workbook #5 perfom steps 1 to 5".

 

My goal is to simply the subflows so that it doesnt have the same "If then" and "Else if then" conditions on every subflow. I want the flow to excute steps 1 through 5.

I have the same question (0)
  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    If all 5 steps are the same for all 7 workbooks, I would have 1 set of subflows, and on my main would look like this:
    "Get Files in Folder" to %Files%

    "ForEach" CurrentItem in Files:

    Do all Subflows

     

  • Community Power Platform Member Profile Picture
    on at

    Thank you for the reply! I appreciate you taking the time to assist me. Would you mind posting a screen shot of what this would look like as I am still learning how to use PAD?

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    MichaelAnnis_0-1627078336518.png

    When creating your subflows, make sure any time you have to point to the "filename", you point to the variable %CurrentItem%.  Example - Launch Excel:

    MichaelAnnis_1-1627078415893.png

    If you are using Windows UI Elements, make sure the selector is generic enough to incorporate all workbooks, for example the Refresh Button:
    Let's say your 7 spreadsheets were all titled Month End Close 1 (2, 3 and so on).  When you first capture the UI element, the selector will be to Month End Close 1.xlsx only.  You can change this, so that it will be captured on all of them, and you don't have to select each separately. Follow these steps:

    1) Go to your UI Elements (in the top right):

    MichaelAnnis_3-1627078772194.png

    2) Hover the mouse over the "Window" Selector, and left click the 3 dots

    MichaelAnnis_4-1627078863636.png

    3) Left click "Edit Selectors"

    MichaelAnnis_5-1627078918101.png

    4)Hover over the text displayed, and click the 3 dots again

    MichaelAnnis_6-1627078950314.png

    5) Left Click "Edit Selector"

    MichaelAnnis_7-1627079097076.png

    #6 was edited 7.26.21

    6) Look for the "Name" box, and manually edit the text under value to something that incorporates all the excel files.  For my example, that would be "Month End Close" and then change the "Equal To" operator to "Contains".

     

    If you have any trouble, let me know.

  • Community Power Platform Member Profile Picture
    on at

    Thank you for this information! I appreciate it. This makes sense but one thing I would like the flow to have is a Display Dialog Box that allows the user to pick which file they want to run the flow on and then have the flow run the sub-flows based on their selection. The subflow actions are all the same regardless of which file they want to run the flow on. Where would I incorporate that into the flow? Below is a screenshot of my current flow. As you can see, the Display Dialog Box will open, the user selects which file from the drop-down menu and then I have several If and Else If conditions performing the same action. How can I use a loop like you have shown me above, to run each subflow based on what the user selects from the drop-down men?

     

    gordo_c_123_0-1627233781487.png

     

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    If you only want 1 workbook ran at a time, I would use a dialog box to establish the workbook.  I am not at my computer, so I can’t check, but if dialogue box has a drop down option, I would use that; otherwise, you could use a number input to dictate which workbook. Then you can define the workbook as a variable based on the selection. To do this, you would use  the “Switch” and “Case” commands to define the workbook variable based on the user selection.

     

    If you want more than 1 workbook ran as an option then I would add a True/False dialog box for each workbook, so they could select only the ones they want ran. Then have the bot say “If true, add file to list” for each dialog box variable, and then loop through the workbooks as we had discussed before. 

    Good luck.

  • Community Power Platform Member Profile Picture
    on at

    Would you be able to provide me with another screenshot of what that would look like? I tried following along but I dont think my actions are ordered correctly.

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    Get files to the list %Files%

    MichaelAnnis_0-1627423167507.png

    In Display "Select List from Dialog", you have them choose from the list of files.

    MichaelAnnis_2-1627423210589.png

    This is what it will look like for the user...they simply check off the workbooks they want to run:

    MichaelAnnis_4-1627423493641.png

    Then you set up the For Each item in %selectedindexes%...for my example, this would be [0] and [1].

    That will give you "Current Item", so it will run [0] first, and then [1] second in my example.

    For Launch Excel, tell it %Files[CurrentItem]%, so the first time, it would be Files[0] and the second time, it would be Files[1].

    MichaelAnnis_3-1627423233257.png

     

    Good luck.

     

     

  • Community Power Platform Member Profile Picture
    on at

    Beautiful - you are such a great help! Sorry but I have one last question: is there a way to rename the list of files in the drop down so that it would show something easier to read like "Workbook #1", "Workbook #2", etc instead of the file paths?

     

    I also do not want to give the user the option to select more than one file to open. When I adjust that setting in the Display Select from list dialog box, I get an error message. Any fix for that?

     

    Would I have to create input variables with the file path and then set variable with the name i want?

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    Instead of %Files% in the dialog box, try %Files.Name%.

  • Community Power Platform Member Profile Picture
    on at

    Not sure what you mean by that, could you clarify?

     

    Instead of running this as a loop, I need it to run once. I want the user to have to choose to run another workbook which would execute the same actions and I accomplished this by using an If condition. I'm almost there: see screenshot below to see what my workspace looks like.

     

    Workspace set up:

    gordo_c_123_1-1627486947710.png

     

    Display Select from list dialog which is where the drop-down menu comes in:

    gordo_c_123_1-1627485256304.png

     

    My If condition:

    gordo_c_123_2-1627485345680.png

     

    Finally, my Launch Excel action:

    gordo_c_123_3-1627485377327.png

     

    This set up gets me to where I want to be: grabs the folder files, displays a drop-down menu of files to choose from, the user clicks on which ever file they want, and it opens the excel workbook.

     

    Now the only remaining issue I have is: below is a screenshot of what the drop-down menu options look like. Long ugly file paths. How can I get the drop-down menu to display a clean looking name such as "Workbook #1, Workbook #2, Workbook #3, etc." instead of a list of file paths?

     

    Screenshot (4)_LI.jpg

     

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard