ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   calling macro in excel from VB program (https://www.excelbanter.com/excel-programming/304402-calling-macro-excel-vbulletin-program.html)

Fung

calling macro in excel from VB program
 
I have an excel file opening all the time for getting real time quote
Can I using a VB program to trigger the excel file to run a macro for some other updates?

Rodney Baker

calling macro in excel from VB program
 
On Mon, 19 Jul 2004 03:35:02 -0700, Fung
wrote:

I have an excel file opening all the time for getting real time quote
Can I using a VB program to trigger the excel file to run a macro for
some other updates?


Yes, you can. You need to define an object in the VB program and bind it
to the Excel type library.

Dim objExcel as Object

Set objExcel = New Excel.Application

Then in your code use

objExcel.Run("<Macro Name", [<arg_1,...,<arg_n]) to cause Excel to
trigger the macro (if that syntax doesn't work, try
objExcel.Application.Run...I can't remember which one is correct).

In VBA, simply use Application.Run("<Macro Name", [<arg1,...,<arg_n]

HTH.

--
Rodney S Baker VK5ZTV



All times are GMT +1. The time now is 08:44 PM.

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