View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Blondie Blondie is offline
external usenet poster
 
Posts: 12
Default Run Access macro from Excel Spreadsheet

I can't get this to work --- can you help?
Sub RunAccessMacro()

Dim appAcc As Access.Application

'Opens Access or gets reference to app already running

Set appAcc = New Access.Application

'Optional to show or hide Access
appAcc.Visible = True

appAcc.OpenAccessProject
"P:\Analytic\Heather\Individual\IndividualTurnover Report.mdb"

appAcc.DoCmd.RunMacro "Macro1: Get Data"
appAcc.DoCmd.RunMacro "Macro2: Create Report"

'Close Access
appAcc.Quit

'This will close Access, even w/o the 'Quit' command
Set appAcc = Nothing

End Sub

"Nick Hodge" wrote:

Karen

You can automate Access like so

Sub AutomateAccess()
Dim acApp As Access.Application
Set acApp = New Access.Application
acApp.OpenCurrentDatabase ("C:\db1.mdb")
acApp.DoCmd.RunMacro "Test", , ""
End Sub

This uses early binding so you will need to set a reference to the MS access
library in advance via the VBE in Excel (ToolsReferences...)

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Karen" wrote in message
...
Is it possible to run an Access macro from an Excel spreadsheet?