I have a spreadsheet with Access query names listed. I want to run those queries in Access through Excel VBA, but instead of opening a new instance of Access, I want to work on the instance (and database) that is already open. The code I currently have is only for the creating new instance:
Sub RunQueries()
Dim appAccess As Object
Set appAccess = CreateObject("Access.Application")
appAccess.Visible = True
appAccess.OpenCurrentDatabase "D:\Access\tysql.accdb", False
Dim QueryName As String
For i = 2 To Queries.Count + 1
QueryName = Cells(i, 1).Value
appAccess.DoCmd.OpenQuery QueryName
Next i
End Sub
I would be grateful for any suggestions.
GetObject(, "Access.Application")instead ofCreateObject("Access.Application")?