Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Facing problem when trying to execute Excel macro

Former Member
0 Likes
655

Hi,

I'm currently opening an Excel document stored within BDS and am trying to populate certain fields before running a macro.

When I was previously using OLE objects to do this, I managed to do this as well as run the macro which was responsible to print a relevant sheet in Excel.

However, as I'm now required to read the document from BDS, I'm using the I_OI_DOCUMENT_PROXY class to run the Excel macro. I've tried using the EXECUTE_MACRO method but I keep getting the error 'MACRO_OR_SCRIPT_FAILED'. Does anyone know what's the cause of this and how do I go about solving this?

Appreciate your help!

Thanks and regards,

Adeline.

1 REPLY 1
Read only

Former Member
0 Likes
468

Hi,

I finally managed to figure this out. As the macro was created within a module, when calling the EXECUTE_MACRO method, the module name would have to be specified first, followed by the actual macro name. Below is an example.

data: doc TYPE REF TO i_oi_document_proxy.

CALL METHOD doc->execute_macro

EXPORTING

macro_string = 'ModPrint.PrintCard'.

where ModPrint is the module and PrintCard is the macro.

Thanks and regards,

Adeline.