LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Check for worksheet in closed workbook

Thanks so much Dave, as i am not a programmer i am a little unsure of
these things but have managed to get it working in the mean time, with
the following code.

Sub DoesSheetExist()
'
Dim myKTLih As String

myKTLih = "90IH0810"


If
IfSheetExists("\\nv09002\tpdrive\Projects\General\ 50_Comparisons\KTL's\"
& myKTLih & ".xls", "TOOL TRACKING") = True Then

Workbooks.Open(FileName:="\\nv09002\tpdrive\Projec ts\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



'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 ***


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Send data to a specific worksheet in a closed Workbook INTP56 Excel Programming 0 July 23rd 07 09:38 PM
Help - How to check if value exists in closed workbook? c mateland Excel Programming 3 April 16th 07 03:05 AM
Check if sheet exists in a closed workbook FrigidDigit[_2_] Excel Programming 2 October 25th 05 06:44 AM
I want a macro that can open a worksheet in a closed workbook bigdaddy3 Excel Programming 12 July 19th 05 06:30 PM
copy worksheet from closed workbook to active workbook using vba mango Excel Worksheet Functions 6 December 9th 04 07:55 AM


All times are GMT +1. The time now is 11:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"