Excel error Popup freezes macro if Excel file is incomplete

I have a UIPath Macro that extracts data from SAP BI and downloads it to a spreadsheet. This file is in the format of a Single File Web Page. Then the macro opens this file with the UiPath Activity ‘Excel Application Scope’. This process works perfect 98% of the time. However occasionally SAP BI gives an incomplete file. Then the Excel Application Scope shows the popup message "MyFileName is not a valid Single File Web Page. " and the macro just freezes. I would expect a timeout error on my next activity, but no it just hangs. How can I handle this situation, so I can move forward in the macro?

Thanks!

  1. modify your macro such that there is exception handling (this will remove the popup)
    image
  • so now if the macro is successful, it returns “Success”
  • otherwise if it fails it simply returns the exception message and wont show any popup
  1. in uipath, declare string to fetch output of “invoke VBA”

  2. handle output

Hi Jack,

Thanks for your response! Perhaps I don’t understand, but I think we have terminology mix-up. When I said I have a “UiPath macro” I mean a UIPath Studio project. I do not have an Excel Macro that I could add your error handling code to.

The issue is when I open the spreadsheet with the UiPath Activity ‘Excel Application scope’ If the file was not downloaded completely for whatever reason I het this popup error. I need this unexpected popup to trigger an error which my existing try/catch logic will retry the process.

Thanks

I see. can you post a screenshot of the error

if that error popup is causing UiPAth to freeze, then its probably blocking the current execution thread.
So we need a separate thread (using “parallel activity” + “Isolated” property) to check if the popup exists and click it

Sequence.xaml (7.6 KB) try click popup.xaml (9.1 KB)

In this diagram, the left sequence will be your main sequence that downloads the excel.
The right sequence (try click popup.xaml) will be the parallel sequence that clicks the error popup if it exists

“try click popup.xaml” will be a loop. It will keep looping until

  1. it sees the error popup (then it will click popup and throw exception), or
  2. excel application scope runs successfully (then it will stop looping)

This is why when excel application scope runs successfully, i added a “write text file” activity to create a text file. Then in “try click popup.xaml”, it will stop looping if this file exists.

try click popup.xaml