cancel
Showing results for 
Search instead for 
Did you mean: 

Add timeout to vba code in code stage

Anonymous
Not applicable
Hi. I have a Code stage that will execute a macro in an excel workbook - and it looks like this: Dim wb as Object = GetWorkbook(Handle, Workbook) Dim excel as Object = wb.Application excel.Run(MacroName)   I would lilke to add some code that will execute a time-out if the macro runs for more than lets say 10 minutes. Is this possible?
2 REPLIES 2

JasonEtchason
Level 3
I believe, when using the BP provided Excel VBO, the macro is blocking and will not return control to your process until the macro terminates. I believe you need to either set the timeout logic in your macro or create a new object with a modified code stage that has timeout logic. It might be better as a code stage, if your macro potentially has errant pop ups that also block. This is something I need to work on as well. Let us know how it goes. Good luck!

david.l.morris
Level 14
Hi Brian, I know this isn't exactly the same as your use case, but I think it's similar enough to warrant looking into. The Excel Automation Guide mentions macros that have a popup and how to deal with that. https://portal.blueprism.com/documents/standard?title=excel&category=All Here's the excerpt that I'm referring to: In some situations, a running Macro requires a response from the user before it can complete. Such macros can cause Blue Prism to “hang” since the Run Macro action will not complete until it has received a response from Excel indicating the user has responded. If this is the case, you will need to use an action which creates a parallel thread while running the macro, meaning control is passed back to Blue Prism as soon as the macro is executed. Blue Prism can then be used to provide a response to the macro. You can request a copy of the Run Macro with Parallel Thread action from Blue Prism Support if you do not already have it in your environment. So you may want to request the 'Run Macro with Parallel Thread' action and see if that'll help you toward a solution. Hope it helps. =) Dave
Dave Morris 3Ci at Southern Company Atlanta, GA