Hello I have this macro in excel that opens access... I would like for it to run a macro once its opened but keep getting errors.
I have:
Global oApp As Object
Sub OpenAccess()
Dim LPath As String
'Path to Access database
LPath = "C:\Database1.accdb"
'Open Access and make visible
Set oApp = CreateObject("Access.Application")
oApp.Visible = True
'Open Access database as defined by LPath variable
oApp.OpenCurrentDatabase LPath
oApp.RunMacro "Macro1"
End Sub
Oapp.RunMacro is what is causing the error...
Copyright © 2024 Q2A.ES - All rights reserved.
Answers & Comments
Verified answer
oApp is the referenced access application.
You are asking Access to run an Excel macro which caused the error.
It is easier to run Access, link its table to your Excel tables and run vba script from Access instead of the other way round..