Hi Bob, thanks for the reply, i have done script like this, but get an
error msg. ?
Could you help ?
Sub DoesSheetExist()
'
If IfSheetExists("TOOL TRACKING") = True Then
Workbooks.Open(FileName:="\\nv09002\tpdrive\Projects\General\50_Comparis
ons\KTL's\" & myKTLIH & ".xls"). _
RunAutoMacros Which:=xlAutoOpen
Else
MsgBox "You have loaded the incorrect KTL", vbOKOnly, "ERROR"
End If
End Sub
'-----------------------------------------------------------------
Function IfSheetExists(FileName As String, sh As String) As Boolean
Dim oConn As Object, myKTL As String
myKTL = "90ZA0810"
Set sh = "TOOL TRACKING"
Set FileName =
"\\nv09002\tpdrive\Projects\General\50_Comparisons\KTL's\" & myKTLIH &
".xls"
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