How can excel macro open access and run macro?

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...

Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Helpful Social

Copyright © 2024 Q2A.ES - All rights reserved.