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

How to call Visual basic MACRO code in ABAP

Former Member
0 Likes
733

Hi all,

I created one MACRO in Microsoft office and now i want to call this macro in my ABAP program.

How to do this can anyone provide me the logic for this....

Regards.

4 REPLIES 4
Read only

Former Member
0 Likes
662

>

> How to do this can anyone provide me the logic for this....

.

I'm sorry if i could not able to give you exact logic, but reading [this stuff |http://www.abapprogramming.net/2008/02/r3-rfc-from-ms-office-via-visual-basic.html]might worth full enough.

Cheers

Read only

Former Member
0 Likes
662

hi,

use this method

This word template has the Macro that will Run when the document is opened using method: cl_gui_frontend_services=>execute

Read only

0 Likes
662

Hi Milan,

Thanks for your help but can u explain more clearly how to use this...method

Read only

0 Likes
662

What Office application/document has the macro? What the other poster was referring to is that you can open any type of Office document, E-mail editor, PDF document, simply by executing the filename or appropriate shell command. By opening the Office document that has the embedded macro, you would trigger that macro to execute. Is that what you need?

Here is a simple example (with a hard-coded filename):


CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
  EXPORTING
    DOCUMENT               = 'C:\temp\mydoc.doc'
  EXCEPTIONS
    CNTL_ERROR             = 1
    ERROR_NO_GUI           = 2
    BAD_PARAMETER          = 3
    FILE_NOT_FOUND         = 4
    PATH_NOT_FOUND         = 5
    FILE_EXTENSION_UNKNOWN = 6
    ERROR_EXECUTE_FAILED   = 7
    SYNCHRONOUS_FAILED     = 8
    NOT_SUPPORTED_BY_GUI   = 9
    OTHERS                 = 10.

As I mentioned, this is also useful for triggering other applications, such as your resident e-mail editor, based on a click of an e-mail address in a GUI screen:


  CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
    EXPORTING
      DOCUMENT               = 'mailto:(put address here)'
    EXCEPTIONS
      CNTL_ERROR             = 1
      ERROR_NO_GUI           = 2
      BAD_PARAMETER          = 3
      FILE_NOT_FOUND         = 4
      PATH_NOT_FOUND         = 5
      FILE_EXTENSION_UNKNOWN = 6
      ERROR_EXECUTE_FAILED   = 7
      SYNCHRONOUS_FAILED     = 8
      NOT_SUPPORTED_BY_GUI   = 9
      OTHERS                 = 10.