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 / how to open Excel file...
Power Automate
Answered

how to open Excel files one by one in a loop from a folder in Power Automate Desktop flow with Example?

(0) ShareShare
ReportReport
Posted on by 203

Hi Everyone,

 

Can anyone help me how To open Excel files one by one in a loop from a folder in Power Automate Desktop flow with Example please?

I have the same question (0)
  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Use the Get files in folder action. This will result in a variable that has a list of files. Then use a For each loop to iterate through the list and use Launch Excel with the %CurrentItem% from the loop action as inputs. This will open each file one by one.

    -------------------------------------------------------------------------

    If I have answered your question, please mark it as the preferred solution.

    If you like my response, please give it a Thumbs Up.

     

    If you are interested in Power Automate, you might want to follow me on LinkedIn at https://www.linkedin.com/in/agnius-bartninkas/

     

  • Ahmedmuz Profile Picture
    203 on at

    Thanks, but all the excel files opening at same time can you please help on this as well please...?
    I want a single file to open then i will make corrections and close and the next excel file have to open. 

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    If you use a For each, the %CurrentItem% will contain a variable with a single file reference. Use that in your Launch Excel action. Then perform all of your actions for corrections and closing Excel inside the loop, so it gets closed before you open the next one.

    -------------------------------------------------------------------------

    If I have answered your question, please mark it as the preferred solution.

    If you like my response, please give it a Thumbs Up.

     

    If you are interested in Power Automate, you might want to follow me on LinkedIn at https://www.linkedin.com/in/agnius-bartninkas/

     

  • Ahmedmuz Profile Picture
    203 on at

    Can u give a example please as we new to PA .. if possible with SS

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Here you go:

    AgniusBartninka_0-1688788012434.png

    You can also copy the following code and paste it directly to your PAD designer. The actions will be created automatically:

    Folder.GetFiles Folder: $'''C:\\RPA''' FileFilter: $'''*.xls*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> Files
    LOOP FOREACH CurrentItem IN Files
     Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: CurrentItem Visible: False ReadOnly: False Instance=> ExcelInstance
     # Perform other Excel actions here
     Excel.CloseExcel.CloseAndSave Instance: ExcelInstance
    END

     

    You will obviously need to change the folder path in Get files in folder. I also applied a filter there to only include Excel files.

    The flow will then loop through the files in a For each loop, open the file and close it.

    You will need to add some actions for modifying your Excel file where I've put the Comment action. I assume you are able to do those yourself. You have not described the modifications needed anyway.

     

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution.
    If you like my response, please give it a Thumbs Up.

    If you are interested in Power Automate, you might want to follow me on LinkedIn at https://www.linkedin.com/in/agnius-bartninkas/

     

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 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard