Macro Help!

Rhys_m_jones

New Member
I am struggling to find a way to run a macro from one open workbook on another open workbook, which are both in the same handle. I am consistently greeted with an exception thrown up by the "code stage".

Steps:
1. Create Excel Instance
2. Show Instance
3. Open File
4. Open Template (where the macro is stored).
5. Activate File
6. Run Macro

The macro itself is relatively easy data manipulation, but unfeasible to do within BP.

Does anybody have any experience of this and/or found a workaround?

Many thanks.
 

cs.andras

Active Member
Hi @Rhys_m_jones
We definitely need to see what the code stage looks like and what kind of exception message is there. This is far from enough info to get started.
 

Rhys_m_jones

New Member
Thanks for the reply @cs.andras

There is no alteration to the coding stage, just simply calling the "Run macro" action from the Excel VBO.

The error itself is:

"Internal : Could not execute code stage because exception thrown by code stage: Cannot run the macro '<MACRO_NAME_HERE>'. The macro may not be available in this workbook or all macros may be disabled."

It seems to be caused by attempting to call a macro that is not within the workbook itself, but from another within the handle. Is there even a way to run a macro from one open workbook on another?
 

cs.andras

Active Member
Hi,
There is a way, something like this:
Code:
Application.Run ("'filename.xlsm'!MacroName")
In BP though... I'm not sure if this will work. Not to mention: are you certain the macros are not disabled?
Regards,
Andras
 

Rhys_m_jones

New Member
Thanks again for your reply @cs.andras

Yeah it's within Blue Prism I need it to occur.

100% they are enabled and available as the same document was used prior with no issues. It seems to be unable to call a macro from one workbook and run it on another, even from within the same handle. If I was experienced in .NET coding I'd be able to just embed the macro within BP.

I have a support ticket with BP open, but so far this hasn't proved fruitful.
 

cs.andras

Active Member
@Rhys_m_jones I meant are they enabled in the opened instance... as you may already know, when you open a workbook fresh, macros are disabled by default and you need to click the Enable Macros button every time. Is this done by BP? Although I'm not sure if it is possible through MS Excel VBO :(
 

anisjolly

Administrator
I'd like to echo what @cs.andras has said, you need to set the Enable Events flag to True (or Enable Macro) - then when you run the Macro, just reference the Macro name in double quotes (i.e. "MyMacro").

Also don't forget to check that the Macro is available under the Macro's list (View Macros) otherwise the Macro won't run in Blue Prism.

@Rhys_m_jones I meant are they enabled in the opened instance... as you may already know, when you open a workbook fresh, macros are disabled by default and you need to click the Enable Macros button every time. Is this done by BP? Although I'm not sure if it is possible through MS Excel VBO :(
 

absak

Member
I had the same thing i had put Enable Events flag (in create instance to true) but the "run macro" does not fonction
 

amador

Member
Similar issue here. I was able to run the excel macro both in Control Panel and in Debug mode, but getting an intermittent error "cannot run macro..."

TOTALLY cannot run it either in Scheduler....I always getting "Cannot run the macro ..." The only difference between running in control Panel and scheduler is the user name.

I thought, the excel containing macros may have not properly loaded so I have added a sleep stage in between but it was the same issue.

View attachment 1545940341953.png
 

marcelopbg94

New Member
Hi!

I had the same issue, i was able to resolve by looking at the exact name on the "Macros" tab inside excel, just like below:

View attachment 1590587916069.png

Apparently, when you transpose a macro to another workbook, even with the same name, it transports a different name than the original, with the workbook name attached. So because of this, "Run macro" cannot undestand the name used.

Hope it helps.
 
Top