ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Run Access macro from Excel Spreadsheet (https://www.excelbanter.com/excel-discussion-misc-queries/123473-run-access-macro-excel-spreadsheet.html)

Karen

Run Access macro from Excel Spreadsheet
 
Is it possible to run an Access macro from an Excel spreadsheet?

Nick Hodge

Run Access macro from Excel Spreadsheet
 
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?



Blondie

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?




All times are GMT +1. The time now is 07:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com