<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Run a macro with ABAP code in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/run-a-macro-with-abap-code/m-p/3977207#M949903</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Loic,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can give this a go:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CREATE OBJECT h_excel 'EXCEL.APPLICATION'.
Call Method of h_excel 'WORKBOOKS' = h_mapl.
set property of h_excel 'VISIBLE' = 0.
Call Method of h_mapl 'OPEN'
EXPORTING
#1 = d_file.
CALL METHOD OF H_EXCEL 'ActiveWorkbook' = h_book .
CALL METHOD OF H_book 'Activesheet' = H_sheet .

CALL METHOD OF h_excel 'RUN'
EXPORTING
#1 = ld_macro.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it works for you and don't forget to reward points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Sougata.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Jun 2008 09:07:25 GMT</pubDate>
    <dc:creator>Sougata</dc:creator>
    <dc:date>2008-06-10T09:07:25Z</dc:date>
    <item>
      <title>Run a macro with ABAP code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/run-a-macro-with-abap-code/m-p/3977205#M949901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everybody,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could someone help me finding a way to run a macro of an excel sheet with an ABAP program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Explanation:&lt;/P&gt;&lt;P&gt;- I launch an abap program that opened an excel sheet with that kind of code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="---------------------------------------------------------------------------------" /&gt;&lt;P&gt;include ole2incl.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : w_excel   type ole2_object,&lt;/P&gt;&lt;P&gt;           w_books   type ole2_object,&lt;/P&gt;&lt;P&gt;           w_book    type ole2_object,&lt;/P&gt;&lt;P&gt;           w_sheets  type ole2_object,&lt;/P&gt;&lt;P&gt;           w_sheet   type ole2_object, &lt;/P&gt;&lt;P&gt;           w_cell    type ole2_object,&lt;/P&gt;&lt;P&gt;           w_rows    type ole2_object,&lt;/P&gt;&lt;P&gt;           w_font    type ole2_object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create object w_excel 'Excel.Application'.&lt;/P&gt;&lt;P&gt;CALL METHOD OF W_EXCEL 'WORKBOOKS' = W_BOOKS.&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;CALL METHOD OF W_SHEET 'CELLS' = W_CELL &lt;/P&gt;&lt;P&gt;       exporting #1 = row&lt;/P&gt;&lt;P&gt;                 #2 = column.&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;CALL METHOD OF W_SHEET 'SAVEAS'.&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With my ABAP program:&lt;/P&gt;&lt;P&gt;- i can open my excel template.&lt;/P&gt;&lt;P&gt;- i can write and format data inside my excel sheet.&lt;/P&gt;&lt;P&gt;- i can close and save my excel sheet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but i don't how to run the macro that exists in my excel template.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2008 09:02:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/run-a-macro-with-abap-code/m-p/3977205#M949901</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-10T09:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: Run a macro with ABAP code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/run-a-macro-with-abap-code/m-p/3977206#M949902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Executing Excel Macro from SAP ABAP &lt;/P&gt;&lt;P&gt;I am populating data in excel sheet using OLE. This excel document contains Macro. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way I can start execution of Macro as soon as data is populated in Excel sheet. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using OLE to populate the Excel Sheet then, then yes you can run a macro. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CALL METHOD OF OBJ_EX_APP 'Run' &lt;/P&gt;&lt;P&gt;       EXPORTING #1 = MACROSTR. &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Adding a Field Exit &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To add a field exit first find the data element that is linked to the screen field- the screen number and program &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Run program RSMODPRF. You will need to create two function modules one FIELD_EXIT_MEPO_VENDOR and &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD_EXIT_MEPO_VENDOR_A &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD_EXIT_MEPO_VENDOR should have code simply of input = ouput. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD_EXIT_MEPO_VENDOR_A should have the code for whatever the functionality is required &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Go back to RSMODPRF and run the program without parameters. Use the push buttons to assign the screen, 'A' and program. Use the drop down to activate the field list. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should now work, but there is no way of debugging. For further information look at OSS 29377 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;program zzdirlist. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;for AIX this method also works. &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF TABL OCCURS 0, &lt;/P&gt;&lt;P&gt;      TEXT(80) TYPE C, &lt;/P&gt;&lt;P&gt;      END OF TABL. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: COMMAND(256) TYPE C. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COMMAND = 'ls'. &lt;/P&gt;&lt;P&gt;CALL FUNCTION 'RFC_REMOTE_PIPE' DESTINATION 'SERVER_EXEC' &lt;/P&gt;&lt;P&gt;EXPORTING COMMAND = COMMAND &lt;/P&gt;&lt;P&gt;READ = 'X' &lt;/P&gt;&lt;P&gt;TABLES PIPEDATA = TABL. &lt;/P&gt;&lt;P&gt;LOOP AT TABL. &lt;/P&gt;&lt;P&gt;   WRITE:/ TABL-text. &lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Open the following link,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/abap/questions-about-bar-code-printing-in-sap.htm" target="test_blank"&gt;http://www.sap-img.com/abap/questions-about-bar-code-printing-in-sap.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jagadish.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2008 09:05:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/run-a-macro-with-abap-code/m-p/3977206#M949902</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-10T09:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: Run a macro with ABAP code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/run-a-macro-with-abap-code/m-p/3977207#M949903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Loic,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can give this a go:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CREATE OBJECT h_excel 'EXCEL.APPLICATION'.
Call Method of h_excel 'WORKBOOKS' = h_mapl.
set property of h_excel 'VISIBLE' = 0.
Call Method of h_mapl 'OPEN'
EXPORTING
#1 = d_file.
CALL METHOD OF H_EXCEL 'ActiveWorkbook' = h_book .
CALL METHOD OF H_book 'Activesheet' = H_sheet .

CALL METHOD OF h_excel 'RUN'
EXPORTING
#1 = ld_macro.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it works for you and don't forget to reward points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Sougata.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2008 09:07:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/run-a-macro-with-abap-code/m-p/3977207#M949903</guid>
      <dc:creator>Sougata</dc:creator>
      <dc:date>2008-06-10T09:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: Run a macro with ABAP code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/run-a-macro-with-abap-code/m-p/3977208#M949904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;CALL METHOD document-&amp;gt;execute_macro&lt;/P&gt;&lt;P&gt;EXPORTING macro_string = macro_string&lt;/P&gt;&lt;P&gt;param_count = param_count&lt;/P&gt;&lt;P&gt;script_name = script_name&lt;/P&gt;&lt;P&gt;param1 = param1&lt;/P&gt;&lt;P&gt;param2 = param2&lt;/P&gt;&lt;P&gt;param3 = param3&lt;/P&gt;&lt;P&gt;param4 = param4&lt;/P&gt;&lt;P&gt;param5 = param5&lt;/P&gt;&lt;P&gt;param6 = param6&lt;/P&gt;&lt;P&gt;param7 = param7&lt;/P&gt;&lt;P&gt;param8 = param8&lt;/P&gt;&lt;P&gt;param9 = param9&lt;/P&gt;&lt;P&gt;param10 = param10&lt;/P&gt;&lt;P&gt;param11 = param11&lt;/P&gt;&lt;P&gt;param12 = param12&lt;/P&gt;&lt;P&gt;no_flush = no_flush&lt;/P&gt;&lt;P&gt;IMPORTING error = error&lt;/P&gt;&lt;P&gt;retcode = retcode&lt;/P&gt;&lt;P&gt;CHANGING error_string = error_string&lt;/P&gt;&lt;P&gt;retvalue = retvalue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2008 09:07:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/run-a-macro-with-abap-code/m-p/3977208#M949904</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-10T09:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: Run a macro with ABAP code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/run-a-macro-with-abap-code/m-p/3977209#M949905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everybody,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i would like to thank you for your help.&lt;/P&gt;&lt;P&gt;I've just tried the code given by Sougata and it works very well.&lt;/P&gt;&lt;P&gt;It was exactly what i'm looking for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks equally to Swastik and Jagadish, i know that your code could be useful to me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jun 2008 12:23:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/run-a-macro-with-abap-code/m-p/3977209#M949905</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-11T12:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: Run a macro with ABAP code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/run-a-macro-with-abap-code/m-p/3977210#M949906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Loic,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  I saw your query and sucess on this... Can you please help me with sample code for this requirement... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  1. from ABAP program i would like to call Excel &lt;/P&gt;&lt;P&gt;  2. Place Macro code in Excel &lt;/P&gt;&lt;P&gt;  or &lt;/P&gt;&lt;P&gt;  3. Calling Excel template which contains Macro&lt;/P&gt;&lt;P&gt;  4. Run the macro from ABAP program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Srinivas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 May 2010 23:14:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/run-a-macro-with-abap-code/m-p/3977210#M949906</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-27T23:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: Run a macro with ABAP code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/run-a-macro-with-abap-code/m-p/3977211#M949907</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sougata,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  I saw your responce on this... Can you please help me with sample code for this requirement... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  1. from ABAP program i would like to call Excel &lt;/P&gt;&lt;P&gt;  2. Place Macro code in Excel &lt;/P&gt;&lt;P&gt;  or &lt;/P&gt;&lt;P&gt;  3. Calling Excel template which contains Macro&lt;/P&gt;&lt;P&gt;  4. Run the macro from ABAP program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Srinivas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 May 2010 23:15:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/run-a-macro-with-abap-code/m-p/3977211#M949907</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-27T23:15:41Z</dc:date>
    </item>
  </channel>
</rss>

