Sub lister_tables_Access()
' Auteur : Pierre - P56 - http://tatiak.canalblog.com/
Dim BDD As String, lg As Integer
Dim Cnx As Object, Cat As Object, Tbl As Object
BDD = "F:\... chemin ...\BaseAccess.accdb"
Set Cnx = CreateObject("ADODB.Connection")
Cnx.Open "DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=" & BDD
Set Cat = CreateObject("ADOX.Catalog")
Set Cat.activeconnection = Cnx
lg = 2
For Each Tbl In Cat.Tables
If Tbl.Type = "TABLE" Then
ActiveSheet.Cells(lg, 1).Value = Tbl.Name
lg = lg + 1
End If
Next
Cnx.Close
Set Cnx = Nothing
Set Cat = Nothing
Set Tbl = Nothing
End Sub
Merci beaucoup. Tout fonctionne parfaitement. Maintenant il ne me reste plus qu'à comprendre ce code.Bonjour,
Voici un exemple
P.VB:Sub lister_tables_Access() ' Auteur : Pierre - P56 - http://tatiak.canalblog.com/ Dim BDD As String, lg As Integer Dim Cnx As Object, Cat As Object, Tbl As Object BDD = "F:\... chemin ...\BaseAccess.accdb" Set Cnx = CreateObject("ADODB.Connection") Cnx.Open "DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=" & BDD Set Cat = CreateObject("ADOX.Catalog") Set Cat.activeconnection = Cnx lg = 2 For Each Tbl In Cat.Tables If Tbl.Type = "TABLE" Then ActiveSheet.Cells(lg, 1).Value = Tbl.Name lg = lg + 1 End If Next Cnx.Close Set Cnx = Nothing Set Cat = Nothing Set Tbl = Nothing End Sub