Application Development 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: 

can't find marco in excel

Former Member
0 Kudos

i record a macro in excel and the name is Macro1, and in sap i using this method to call the macro

CALL METHOD document->execute_macro

EXPORTING

macro_string = 'Macro1'.

but the system can't find the macro,how to define the macro string?

thanks!

7 REPLIES 7

former_member181962
Active Contributor
0 Kudos

Try with capital Letters.

Regards,

ravi

Former Member
0 Kudos

I changed the macro string to captial letters,but it not work

and the error string is: can't find macro “ThisWorkbook.MACRO1”

0 Kudos

Can you tell us what class are you using?

In other words,

how was the object document created(With referance to whichh class?)

Regards,

Ravi

Former Member
0 Kudos

CALL FUNCTION 'DP_PUBLISH_WWW_URL'

EXPORTING

OBJID = 'ZSRM_TMX_PRINT'

LIFETIME = 'T'

IMPORTING

URL = URL.

CALL METHOD C_OI_CONTAINER_CONTROL_CREATOR=>GET_CONTAINER_CONTROL

IMPORTING

CONTROL = CONTROL.

CREATE OBJECT CONTAINER

EXPORTING

CONTAINER_NAME = 'VIEW'.

CALL METHOD CONTAINER->SET_VISIBLE

EXPORTING VISIBLE = 'X'.

CALL METHOD CONTROL->INIT_CONTROL

EXPORTING

R3_APPLICATION_NAME = 'SRM'

INPLACE_ENABLED = INPLACE

PARENT = CONTAINER.

CALL METHOD CONTROL->GET_DOCUMENT_PROXY

EXPORTING

DOCUMENT_TYPE = 'Excel.Sheet'

IMPORTING

DOCUMENT_PROXY = DOCUMENT.

CALL METHOD DOCUMENT->OPEN_DOCUMENT

EXPORTING

OPEN_INPLACE = INPLACE

DOCUMENT_URL = URL.

CALL METHOD DOCUMENT->GET_SPREADSHEET_INTERFACE

IMPORTING

SHEET_INTERFACE = SPREADSHEET.

*append value to excel

data:ERROR_STRING(255).

CALL METHOD document->execute_macro

EXPORTING

macro_string = 'MACRO1'

NO_FLUSH = ' '

changing

ERROR_STRING = ERROR_STRING.

Former Member
0 Kudos

somebody help me

Former Member
0 Kudos

Try this:

macro_string = 'module1.Macro1'

It works !

Look at demos:

SAPRDEMOEXCELINTEGRATION

SAPRDEMOEXCELINTEGRATION2

SAPRDEMOOFFICEINTEGRATION

best regards,

Robert