Reputation: 25
I am trying to call a subroutine from the Access file "Hey.accdb" using the Excel file "Hoy.xlsm". The subroutine's name is "HelloWorld" with parameter "Para01" which is a string.
Here's my coding in the Excel file which does not work:
Sub RunSubinAccesswithPara()
'Open Access file
Set Db = CreateObject("Access.Application")
Db.OpenCurrentDatabase "D:\Database1\Hey.accdb"
Db.Visible = True
Db.AutomationSecurity = msoAutomationSecurityLow
Db.Execute "HelloWorld('Y')"
End Sub
Any help is appreciated.
Upvotes: 1
Views: 70
Reputation: 1172
You can use the Application.Run method like so:
DB.Run "HelloWorld", "Y"
Upvotes: 1