ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run a macro in a workbook through VB6 (https://www.excelbanter.com/excel-programming/308801-run-macro-workbook-through-vb6.html)

Eric Marple

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

Frank Stone

Run a macro in a workbook through VB6
 
hi,
If the macro is in the current WB then
toolsMacrosmacrorun 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

-----Original Message-----
What is the proper syntax to run a macro which has
parameters in a specified workbook?
.


Eric Marple

Run a macro in a workbook through VB6
 
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?
-----Original Message-----
hi,
If the macro is in the current WB then
toolsMacrosmacrorun 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

-----Original Message-----
What is the proper syntax to run a macro which has
parameters in a specified workbook?
.

.


Stephen Bullen[_3_]

Run a macro 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



Tushar Mehta

Run a macro in a workbook through VB6
 
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

In article ,
says...
What is the proper syntax to run a macro which has
parameters in a specified workbook?



All times are GMT +1. The time now is 06:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com