If your goal is simply to check whether a db file contains a specific linked table, you can use the ADO OpenSchema
method. With that approach, you don't need to open the db file in an Access application session, so the AutoExec macro does not run.
Below is an example using late binding. I left comment notes in case you prefer early binding. Change the Provider if your Access version is older than 2007.
Since you're using Access user-level security, you will also have to adapt the connection string to include the path to your MDW and supply the Access security user name and password. Here is an example connection string (using the Jet 4 provider) from ConnectionStrings.com. I split the single-line string on the semicolons for readability:
Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=C:\mydatabase.mdb;
Jet OLEDB:System Database=system.mdw;
User ID=myUsername;
Password=myPassword;
Public Function HasLinkedTable(ByVal pDb As String, _
ByVal pTable As String) As Boolean
Const adSchemaTables = 20&
Dim cn As Object ' ADODB.Connection
Dim rs As Object ' ADODB.Recordset
Dim strConnect As String
Dim blnReturn As Boolean
strConnect = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & pDb & ";"
'Set cn = New ADODB.Connection
Set cn = CreateObject("ADODB.Connection")
cn.Open strConnect
Set rs = cn.OpenSchema(adSchemaTables)
With rs
Do While Not .EOF
If !TABLE_NAME = pTable And !TABLE_TYPE = "LINK" Then
'Debug.Print !TABLE_NAME, !TABLE_TYPE
blnReturn = True
Exit Do
End If
.MoveNext
Loop
.Close
End With
cn.Close
Set cn = Nothing
HasLinkedTable = blnReturn
End Function