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

Problem with i_oi_document_proxy->execute_macro

Former Member
0 Likes
3,041

Hi experts.

I 'm using class  document_proxy for export some table to Excel.

But I can't execute macro using method document_proxy->execute_macro( ).

Text macro is:

Sub test ()

Range("A5:E28").select

End Sub

The message is:   TYPE MISMATCH: 'Range'.

Maybe somebody faced such problem and can help me to solve it?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,701

  I 've got one more question.  We have implemented the editor for entering Vbscript text and we need syntax check entering text. It is possible to implement it in SAP.

13 REPLIES 13
Read only

Sandra_Rossi
Active Contributor
0 Likes
2,701

did you try:

set x = excel.activeworkbook

x.range("A5:E28").select

Read only

Sandra_Rossi
Active Contributor
0 Likes
2,701

did you separate macro lines with CR_LF ?

did you try with the simplest call : msgbox("hello world") ?

Read only

0 Likes
2,701

Hello, Rossi.

Thanks for help. Yes I separate micro lines with CR_LF.

I will try first variant and I got an error 'Object required: excel'.

Read only

0 Likes
2,701

did you try with the simplest call : msgbox("hello world") ?

Read only

0 Likes
2,701

Simplest call msgbox("hello world") is work. But if I use excel objects such as Excel, Worksheet, Range the execute_macro( ) do not understand it.

Read only

0 Likes
2,701

I did a test, and we need to add Set excel = GetObject(,"Excel.Application"), then excel.range("A5:E28").select should work

Read only

0 Likes
2,701

Thanks very much, it is work.

But I thought that execute_marco( ) execute VBA macro, but it turns out that is VBscript macro.

Read only

0 Likes
2,701

Yes, with DOI, you may only select VBscript or javascript.

Read only

0 Likes
2,701

Thanks Sandra very much. I am understand.

Read only

Former Member
0 Likes
2,702

  I 've got one more question.  We have implemented the editor for entering Vbscript text and we need syntax check entering text. It is possible to implement it in SAP.

Read only

0 Likes
2,701

No idea (maybe write it to a local .vbs file, and call cl_gui_frontend_services=>execute). I always do it that way: first, record the VBA macro (manual actions recorded automatically), adjust it to make it work according to your requirements, then copy it to a VBS file run it and edit it until it works (there are few rules to know to convert a VBA into a VBS).

Read only

0 Likes
2,701

Hello, Sandra.

Thanks for the idea.

Read only

Former Member
0 Likes
2,701

In continuation of the issue.

When we use execute_macro,  we write in marco text such as ws.Range("A3").Value = "Сережа", that is we want write Russian text in cell, but when the macro runs in Excel cell we see abracadabra(jubberwocky). It seems what problem with encoding, but we could not find parameter Encoding in execute marco or in add_marco.

Maybe somebody knows where we can specify the encoding?