I am working on this project which calls a macro to process files. My concern is that there are instances wherein the macro fails to execute properly, like it opens a dialogue box saying that there’s a runtime error, but when I try to rerun, the process will proceed smoothly.
Is there any way I can enforce a timeout for macro execution? Like if 30 mins have passed and the macro hasn’t finished, then I’ll kill the excel process then throw an exception.
I tried using the parallel activity but the robot still waits for the macro to finish before it proceeds or go back to other branch.
Also…you can include a try catch in your macro so that any error occuring on macro can be caught and it wont open a dialog box and can actually return normally and can throw the error back to UiPath as well
This is the structure.DisplayAlerts will stop all message boxes
Function RenameSheet ()
Application.DisplayAlerts = False
On Error GoTo eh
ActiveSheet.Name = "Sheet1"
Application.DisplayAlerts = True
RenameSheet = "Success"
Exit Function
eh:
Application.DisplayAlerts = True
RenameSheet = Err.Description
End Function
I tried the sample you gave, however, I was wondering how I could determine if excel was indeed stuck. Is it safe to assume that once the flow passes the Kill Process, then it’s stuck?
Please check this this is how you can write…and this is a function so it would give a return value to UiPath…when successful it gives success…when failed you get the error message in the output
Function Call_Macro()
Application.DisplayAlerts = False
On Error GoTo eh
Call UnzipFiles
Call ClearDump
Call AppendData
Call SaveBook
Application.DisplayAlerts = True
Call_Macro = "Success"
Exit Function
eh:
Application.DisplayAlerts = True
Call_Macro = Err.Description
End Function
Thank you, @Anil_G and @Yoichi ! I really appreciate your help. I’ve tried to implement your suggestions and both worked! Such great approach and ideas that I would definitely use from here onwards.