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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Automate
Unanswered

Cleanup on error

(0) ShareShare
ReportReport
Posted on by 63

Is there a way to cleanup stuff on error on a global level? I want to always close any open Excel file for instance. Can't really use OnBlockError I guess since I use lots of subflow, or will the OnBlockError catch stuff that happens in a subflow also?

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

    I believe if you OnBlock Error the main tab, you could go to a CloseAll subflow and run through the following for all possible open windows:

     

    If Window (by Title) is open,

    Focus Window

    #do something (like save if needed)

    Close Window

  • yoko2020 Profile Picture
    495 on at

    @roccolord 


    @roccolord wrote:

    Is there a way to cleanup stuff on error on a global level?

    Use OnBlockError

     

     



    @roccolord wrote:

    I want to always close any open Excel file for instance. Can't really use OnBlockError I guess since I use lots of subflow, or will the OnBlockError catch stuff that happens in a subflow also?

    Yes, OnBlockError will catch stuff inside subflow. You can use dirty way Terminate process Excel action for closing any open excel.


  • Pavel_NaNoi Profile Picture
    1,074 on at

    On-block will work with sub-flows, you should re-direct any errors that it catches to another subflow that will do what the guys above have suggested, another method incase you need it is to use a "Get window" with foreground option and "Close window" activities together in a while loop which checks for "Close window" to throw an error

    (simply have an on-error for "Close window" that sets a variable for the while loop to check),

     

    Once it does detect one, it ends as it has reached the desktop and cannot close anything further. This won't work if the windows are minimized though.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 223

#2
David_MA Profile Picture

David_MA 210 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 175

Last 30 days Overall leaderboard