L
Les Stout
Hi all,
I got the function below from Bob Phillips yesterday and would like to
know if it is possible for it to give me the name of the sheet that it
finds ?
Any help would be much appreciated...
Function IfSheetExists(FileName As String, sh As String) As Boolean
Dim oConn As Object
'FileName = "\\nv09002\tpdrive\Projects\General\50_Comparisons\KTL's\" &
myKTLih & ".xls"
'sh = Worksheets("TOOL TRACKING")
Set oConn = CreateObject("ADODB.Connection")
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & FileName & ";" & _
"Extended Properties=Excel 8.0;"
On Error Resume Next
oConn.Execute "SELECT 1 FROM [" & sh & "$] WHERE 0=1"
IfSheetExists = (Err.Number = 0)
oConn.Close
Set oConn = Nothing
End Function
Best regards,
Les Stout
*** Sent via Developersdex http://www.developersdex.com ***
I got the function below from Bob Phillips yesterday and would like to
know if it is possible for it to give me the name of the sheet that it
finds ?
Any help would be much appreciated...
Function IfSheetExists(FileName As String, sh As String) As Boolean
Dim oConn As Object
'FileName = "\\nv09002\tpdrive\Projects\General\50_Comparisons\KTL's\" &
myKTLih & ".xls"
'sh = Worksheets("TOOL TRACKING")
Set oConn = CreateObject("ADODB.Connection")
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & FileName & ";" & _
"Extended Properties=Excel 8.0;"
On Error Resume Next
oConn.Execute "SELECT 1 FROM [" & sh & "$] WHERE 0=1"
IfSheetExists = (Err.Number = 0)
oConn.Close
Set oConn = Nothing
End Function
Best regards,
Les Stout
*** Sent via Developersdex http://www.developersdex.com ***