Sub test()
Dim Connexion As Object: Set Connexion = CreateObject("Adodb.connection")
With Connexion
.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ThisWorkbook.FullName & ";Extended Properties=""Excel 12.0;HDR=YES;""" 'à la place de ThisWorkbook.FullName tu écris le chemin du fichier.xlsx dan Access!
t = ListeChampTable(Connexion, "Feuil1$")
Debug.Print ChampExist(Connexion, "Feuil1$", "A")
.Close
End With
End Sub
Function ListeChampTable(Connexion As Object, table As String)
Dim t() As String, i As Integer
With Connexion
With .OpenSchema(4, Array(Empty, Empty, table))
While Not .EOF
ReDim Preserve t(i)
t(i) = !COLUMN_NAME
i = i + 1
.MoveNext
Wend
ListeChampTable = t
End With
End With
End Function
Public Function ChampExist(Connexion As Object, table As String, Champ As String) As Boolean
With Connexion
With .OpenSchema(4, Array(Empty, Empty, table))
If Not .EOF Then
.Filter = "COLUMN_NAME ='" & Champ & "'"
ChampExist = Not .EOF
End If
End With
End With
End Function