Run a macro in a workbook through VB6

E

Eric Marple

What is the proper syntax to run a macro which has
parameters in a specified workbook?
 
F

Frank Stone

hi,
If the macro is in the current WB then
tools>Macros>macro>run should do it. you will be prompted
of the perameters.
If the macro is to be run on another WB then code must be
add to open the other workbook.
ChDir "C:\dir1"
Workbooks.Open Filename:="C:\Dir1\file2.xls"
or if open to activate the file.
Windows("file2.xls").Activate
 
E

Eric Marple

Actually I need to run a macro in a specific workbook
throufh a VB.exe I wrote. The excel workbook is never
visible. How do I run a function that takes parameters in
a workbook through VB6?
 
S

Stephen Bullen

Hi Eric,
What is the proper syntax to run a macro which has
parameters in a specified workbook?

From VB:

xlApp.Run "WorkbookName.xls!RoutineName", arg1, arg2

where xlApp is a variable referencing the Excel Application object.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.ie
 
T

Tushar Mehta

Check the Application object's Run method.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
Top