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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Ivan F Moala

MrExcel MVP
Joined
Feb 10, 2002
Messages
4,209
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")
 

Beatrix

New Member
Joined
Sep 5, 2002
Messages
5
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. :)
 

Ivan F Moala

MrExcel MVP
Joined
Feb 10, 2002
Messages
4,209
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"
 

Forum statistics

Threads
1,143,641
Messages
5,719,988
Members
422,257
Latest member
Calion

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
Top