Whats the Best Way to Run Excel Macro from VB

Beatrix

New Member
Joined
Sep 5, 2002
Messages
5
i wrote a VB apps link to excel and my way of doing it is through Shell and SendKey command from my VB Apps to excel. It runs fine however, i cant do other tasks while this application runs. Are there better alternatives on these. Will the ActiveX or OLE approach simplify things for me? How? :)
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
On 2002-09-11 19:36, Beatrix wrote:
i wrote a VB apps link to excel and my way of doing it is through Shell and SendKey command from my VB Apps to excel. It runs fine however, i cant do other tasks while this application runs. Are there better alternatives on these. Will the ActiveX or OLE approach simplify things for me? How? :)

Set a reference to the Excel application object...this will expose all the class objects that you would normally use in excel VBA et all.

eg

creatobject("Excel.Application")

Set xlApp = CreateObject("Excel.Application")
 
Upvote 0
thx ivan for the swift reply....can i run my excel macro with your suggestion? Can these macros be called from VB. Im using VB and havent tried VBA yet. :)
 
Upvote 0
On 2002-09-11 20:18, Beatrix wrote:
thx ivan for the swift reply....can i run my excel macro with your suggestion? Can these macros be called from VB. Im using VB and havent tried VBA yet. :)

Yes you can..you just need to reference it correctly eg.

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook

Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open "C:WorkMyFile.xls"

WkBk.Run "MyMacroName"
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,618
Members
449,092
Latest member
amyap

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top