This works for me. It requires you to set a reference to the Microsoft
ADO Ext. 2.X for DDL and Security object library as well as the normal ADO
object library.
The ADODB OpenSchema has a slight advantage in that you can specify to
exclude system tables, requires only one ADO library (actually, Rob's
only requires ADOX), plus you get a recordset object to work with e.g.
can Sort, Filter, GetRows, etc. Modified Rob's code:
Option Explicit
Sub GetTableNames()
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim lRow As Long
Dim szConnect As String
Sheet1.UsedRange.Clear
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Tempo\New_Jet_DB.mdb;"
Set cnn = New ADODB.Connection
cnn.CursorLocation = adUseClient
cnn.Open szConnect
Set rs = cnn.OpenSchema( _
adSchemaTables, _
Array(Empty, Empty, Empty, "Table"))
With Sheet1
.Range(.Range("A1"), _
.Range("A1").Cells(rs.RecordCount)) _
.Value = Application.Transpose( _
rs.GetRows(, , "TABLE_NAME"))
End With
rs.Close
cnn.Close
End Sub
Jamie.
--