I\'m trying to get a list of all tables from an Access 2007 ACCDB format database using Excel VBA.
I have followed this post:
How can I get table names from
I was able to make the code work with a MDB file. I had the option to set the user permissions using "Database Tools - Users and Permissions" on the ribbon. This option is only available for MDB files. Now the problem is to make it work with a ACCDB file.
Here is my code:
Dim DBFile As String
Dim Connection As ADODB.Connection
Dim Recordset As New ADODB.Recordset
DBFile = "C:\Documents and Settings\User\Desktop\Son.mdb"
Set Connection = New ADODB.Connection
Connection.Open "Provider=Microsoft.ACE.OLEDB.12.0; Data Source= " & DBFile & ";"
SQLString = "SELECT MSysObjects.Name AS table_name" & _
"FROM MSysObjects WHERE (((Left([Name],1))<>" & """~""" & ")" & _
"AND ((Left([Name], 4))<>" & """MSys""" & ")" & _
"AND ((MSysObjects.Type) In (1,4,6)));order by MSysObjects.Name"
Set Recordset = New ADODB.Recordset
Recordset.Open SQLString, Connection
The problem is that I can't make it work with ACCDB files.