calling macro in excel from VB program

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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.
 

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