Highlighted
Absent Member.
Absent Member.
812 views

[archive] Execute VBA Macro with Excel OLE

[Migrated content. Thread originally posted on 27 August 2003]

Does anyone knows how to execute a VBA macro when using Excel OLE in AcuGT?

I have a worksheet Book1.xls wich contains the macro Macro1. With the Excel OLE sample program I found in this forum, I open this workbook and try to execute the macro with the following statement:

MODIFY hExcelApp @Run "Book1.xls!Macro1"

But this doesn't work. What am I doing wrong?
0 Likes
2 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Execute VBA Macro with Excel OLE

I just found the solution for my problem:

MODIFY [B]hExcelWks[/B] @Application::Run "Book1.xls!Macro1"
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Execute VBA Macro with Excel OLE

To run a macro, you have to tell in which file the macro is. This file also has to be loaded. Like:

Assume MyMacro in file: MyMacros.xlm. To run it, you would first have to have the workbook load the MyMacros.xlm, then you would invoke the macro by:

MODIFY hExcel @Run("MyMacros.xlm!MyMacro")

If the macro returns something, remember GIVING

Finally, if parameters are required they are given like:

MODIFY hExcel @Run("MyMacros.xlm!MyMacro", p1, .., pn)

Note, Excel does not allow objects to be passed as parameters to the run method.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.