Showing results for 
Search instead for 
Did you mean: 
New Member

Excel Loop Error

I have a flow that is based on a loop which opens an excel file in a particular folder directory, runs a macro on the open excel instance (to find and replace a list of keywords), closes excel, and then moves onto the next excel file in the directory. This works pretty well and cycles through a long list of files I have. However, if an excel file fails to launch properly (for whatever reason), this causes an error which terminates the flow.


Is there a way for me to just ignore any file that doesn't open correctly (and for that matter an error for any reason) and move on to the next file in the directory (i.e. so the flow works through every file and only skips those which cause an error). Ideally I'd get a list of the files that hadn't been processed, though this would just be a bonus.



Post Prodigy
Post Prodigy

Have you tried using On Block Error?




Super User
Super User

You can use the in-action error functionality of every action.

For example, Launching the Excel has its own set of Error Handlers


Refer the Advanced section:




Under the New rule button you can set a Flag variable. For Eg 1 if error and 0 if no error.

Enable "Continue Flow run" and select "continue next action"

Immediately after, have an If statement which will check this Flag value.

If 1 then add this file name to a List variable, that way you will also have a list of Excel files that failed.


Sometimes some error handlers do not capture specific types of errors. In that case encapsulate it with a on block error just like @ryule has suggested.



Helpful resources

Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,993)