View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Eric White[_2_] Eric White[_2_] is offline
external usenet poster
 
Posts: 45
Default Run Access Macro from within Excel

The easiest way is to set a reference in your Excel project to the Access
object library. (Tools - References, and scroll down to find "Microsoft
Access XX.0 Object Library," and check the box.) This will allow you to get
all the Intellisense features for Access. So, in Excel

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.Open "C:\Database with the Macro.mdb"


'For running a regular Access macro
appAcc.DoCmd.RunMacro "MyAccessMacro"

'For running a VBA macro
appAcc.RunMacro "MyAccessMacro"

'MORE OF YOUR CODE

'Close Access
appAcc.Quit

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

End Sub



"Thebeej" wrote:

I am new to macro programming. It is possible to run an Access Macro from an
Excel spreadsheet? Can you open Access, run the macro, close Access from the
spreadsheet?