In order to call an Access vba procedure from an Excel spreadsheet, the first thing you need in Excel is a Reference for the Microsoft Access Object Library, as seen in the picture below ...
To see this screen, from within Excel, go to VBA (press ALT + F11), then select Tools from the top menu and then References
Public Sub ProcedureInAccess()
‘this VBA code is run in Excel
Dim acApp As Object
Dim db As Object
Set acApp = CreateObject("Access.Application")
acApp.OpenCurrentDatabase ("C:\MyDatabaseName.mdb")
Set db = acApp
acApp.Run "NameOfProcedureInAccess"
acApp.Quit
Set acApp = Nothing
End Sub
Wednesday, November 02, 2005
Subscribe to:
Post Comments (Atom)
1 comment:
There is little error
You need: Set db = acApp
Not: Set db = CurrentDb
Post a Comment