View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rodney Baker Rodney Baker is offline
external usenet poster
 
Posts: 7
Default 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