I am using Excel 2013 and Accesss 2013. I am trying to use Excel <acronym title="visual basic for applications">VBA</acronym> to open Access and run a specific query. I run the below code, then it highlights the "Dim appAccess As Access.Application" line and gives me the error message "Compile error: User-defined type not defined". I am not quite sure how to fix this. Any help is appreciated!
Sub RunAccess()
'Update Access Table
Dim strDatabasePath As String
Dim appAccess As Access.Application
strDatabasePath = "N:\Data\Data.accdb"
Set appAccess = New Access.Application
With appAccess
Application.DisplayAlerts = False
.OpenCurrentDatabase strDatabasePath
.DoCmd.OpenQuery "qry_Shipments_West/East_Final"
.Quit
End With
Set appAccess = Nothing
End Sub
Sub RunAccess()
'Update Access Table
Dim strDatabasePath As String
Dim appAccess As Access.Application
strDatabasePath = "N:\Data\Data.accdb"
Set appAccess = New Access.Application
With appAccess
Application.DisplayAlerts = False
.OpenCurrentDatabase strDatabasePath
.DoCmd.OpenQuery "qry_Shipments_West/East_Final"
.Quit
End With
Set appAccess = Nothing
End Sub