1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
Option Explicit
Const FullPathFile$ = "z:\test"
Const SheetName$ = "Feuil1"
Sub main()
Dim repertoire As String, feuille As String
repertoire = "Z:\Développement\ClasseurZ": feuille = "Feuil1"
MsgBox OkSheetName(repertoire, feuille)
End Sub
Private Function OkSheetName(FullPathFile$, SheetName$) As Boolean
Dim Con As Object, Cat As Object, Tbl As Object
Set Con = CreateObject("ADODB.Connection")
Con.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" _
& FullPathFile & ";" & "Extended Properties=Excel 8.0;"
Set Cat = CreateObject("ADOX.Catalog")
Set Cat.ActiveConnection = Con
For Each Tbl In Cat.Tables
If Left$(Tbl.Name, Len(Tbl.Name) - 1) = SheetName Then
OkSheetName = True
Exit For
End If
Next Tbl
Set Cat = Nothing: Con.Close: Set Con = Nothing
End Function |
Partager