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 / Excel Process remains ...
Power Automate
Unanswered

Excel Process remains open after PAD closes Excel

(0) ShareShare
ReportReport
Posted on by

I have intermittent issues with attended flows that need to use excel but fail as the desktop sees excel as still open when a previous step has closed excel. 

I have a number of flows that contain multiple steps that download data from websites as excel files. I then run steps to open the excel spreadsheet, run some routines on the data, then close the excel file when Im finished with it. As this needs to then be repeated with another website, it needs to then open a new excel instance and repeat the process. Obviously the instances are all unique. When the flow fails and the error message relates to an excel instance, I can see that there are still one or more excel processes running in the background and closing these manually allows me to complete the flow. 

As I have some excel files (and powerpoint files) getting data from excel spreadsheets intermittently through the day, I wonder if its these functions that are causing the "rogue" excel processes to remain open and "confuse" my mail hourly flow. 

Any help would be gratefully received? 

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

    Well, up until the last paragraph, my answer was going to be “Kill all Excel.exe” after each website loop. 

    This would terminate any Excel running on the computer, same as if you manually went to Task Manager and right click -> end task on each Excel process you found. 

    The concern would be unaccounted Excel running and accidentally closing one of those.   So, here is the best workaround I can think of:

     

    On the other flows that aren’t part of this one, start the flow with an environment variable %DoNotCloseExcel% and set it to TRUE.  When the flow is complete, set the variable to FALSE.

     

    Now, in this one, after each website, when you want all prior excel closed, you could say:

    Loop
         Get Environment Variable %DoNotCloseExcel%
         If %DoNotCloseExcel% = FALSE

               Kill Excel.exe

               Exit Loop

        Else

            Wait 1 min

        EndIF

    End

     
    This will stop in the loop until Excel can be closed and kill all excel.exe before moving onto the next website. 

    Best of luck!

  • VJR Profile Picture
    7,635 on at

    Hi @JimGr 

     

    I tried to re-create the situation you are explaining by working with multiple Excel files from PAD.

     

    Below are my observations and some inputs that you could try:

    • Used "Launch Excel" and performed some data operations and then used "Close Excel"
      • The Excel process in the Task Manager was correctly getting closed. But I observed that it was closing after a few seconds and not immediately. 
      • So please add some wait before trying any other Excel related activity
    • Accidentally tried another thing :). Had not closed the Excel (neither manually nor via PAD) that was previously open by PAD and then again called "Launch Excel". The Excel file opened up but obviously in read -only mode. So now I could see 2 Excel processes in the Task Manager.
      • So make sure that any Excel instances opened (using this flow or any other flow) are closed correctly using the "Close Excel" action.

    I am sure doing these things would pretty much work.

    Will keep a watch on what you come up with.

     

    Good day!

  • AshleyPettit Profile Picture
    40 on at

    Hey @JimGr,

     

    One option is to use

     

    Excel Task ->

    'On error' -> Continue flow Run. 

     

    On error is found as a little blue shield at the bottom left of the task. 

     

    Now if you attempt to open an excel file that is already open the flow won't crash.

     

    Alternatively, you can force close excel. "Terminate process" -> excel

     

    Hope this helps.

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

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard