Hi -
you can try this function to check whether the sheet named "extract" is in the closed workbook.
Function checkSheetName(fName As String) As Boolean
Dim con As Object, cata As Object, tbl As Object
Set con = CreateObject("ADODB.Connection")
Set cata = CreateObject("ADOX.Catalog")
con.Open "Provider=MSDASQL.1;Data Source=Excel Files;Initial Catalog=" & fName
Set cata.ActiveConnection = con
For Each tbl In cata.Tables
If InStr(tbl.Name, "extract") > 0 Then
checkSheetName = True: Exit For
End If
Next
Set cata = Nothing: Set con = Nothing
End Function
use it like;
sub test()
msgbox checkSheetName("c:\test.xlsx")
end sub
event
Bookmarks