Running Excel Macro from Access (cont'd)?

chazan

New Member
Joined
Jan 6, 2003
Messages
3
First of all I am using Access 97. Before using the following code I reference the Microsoft Excel 8.0 Object Library. The code doesn't run though- when I try to execute nothing happens. Here is the code:

Option Compare Database
Option Explicit

Sub RunXlMacro()
Dim appXL As Excel.Application
Dim wbk As Excel.Workbook

Set appXL = New Excel.Application

Set wbk = appXL.Workbooks.Open("D:DeleteMe.xls")

appXL.Run wbk.Name & "!Test"
wbk.Close False
appXL.Quit

Set appXL = Nothing

End Sub

I am new so please excuse my ignorance :) Thanks.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
On 2003-01-08 13:56, chazan wrote:
First of all I am using Access 97. Before using the following code I reference the Microsoft Excel 8.0 Object Library. The code doesn't run though- when I try to execute nothing happens. Here is the code:

Option Compare Database
Option Explicit

Sub RunXlMacro()
Dim appXL As Excel.Application
Dim wbk As Excel.Workbook

Set appXL = New Excel.Application

Set wbk = appXL.Workbooks.Open("D:DeleteMe.xls")

appXL.Run wbk.Name & "!Test"
wbk.Close False
appXL.Quit

Set appXL = Nothing

End Sub

I am new so please excuse my ignorance :) Thanks.

Hi, Ive never tried to do this before, but in a test I did the following where Test is the name of a macro within the Excel file....

Code:
Sub RunXlMacro()
Dim appXL As Excel.Application
Dim wbk As Excel.Workbook

Set appXL = New Excel.Application
Set wbk = appXL.Workbooks.Open("C:1.xls")

appXL.Run "Test"
appXL.Quit

Set appXL = Nothing

End Sub

Are you trying to run an Excel macro or an Access macro?

EDIT: Note that backslashes in the path are in the code but dont appear in this post - something to do with BBCode and HTML.
_________________
cheers
Parry
This message was edited by parry on 2003-01-22 16:44
 
Upvote 0

Forum statistics

Threads
1,221,507
Messages
6,160,219
Members
451,631
Latest member
coffiajoseph

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