Running Excel Macro from Access

Yugo

New Member
Joined
Oct 18, 2004
Messages
36
Hello,

a similar problem to one already solved just below... In my procedure in Access I can open my excel document no problems but what I would like to do run a macro from that spreadsheet. How do I do that?

Also is it possible to import a module into an Excel workbook from a procedure in Access?

Cheers

Yugo
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
This code will allow you to open and control Excel from Access. Once you open the application and Workbook, you should be able to call your macro directly from the Access VBA Code.

HTH
Cal

Code:
Dim XL As Object
Dim Excel As Object
Dim FullPath as String

FullPath = 'Your Path & FileName
Set XL = CreateObject("Excel.Application")
XL.Workbooks.Open (FullPath)
XL.Visible = False

Add you macro call here

WB.Close
XL.Quit
 
Upvote 0
hmmm as easy as just calling the procedure as normal... cool.

i read Chip Pearson's guide to working with code within code... so both questions are sorted

Thanks
 
Upvote 0
Quick Note. I ran some tests(Since I've never actually ran a Excel Macro from Access). You need to call the macro using the xl.run and then the macro name in qoutes. Otherwise Access chokes on it as a undefined function.

XL.Run "message"
 
Upvote 0
I see. I did think I would need something to tell Access to look for the macro in excel....

Thanks again...
 
Upvote 0

Forum statistics

Threads
1,221,821
Messages
6,162,157
Members
451,750
Latest member
pnkundalia

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