Run a macro in a workbook through VB6

  • Thread starter Thread starter Eric Marple
  • Start date Start date
E

Eric Marple

What is the proper syntax to run a macro which has
parameters in a specified workbook?
 
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
 
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?
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top