PC Review


Reply
Thread Tools Rate Thread

Check for worksheet in closed book - Help

 
 
Les Stout
Guest
Posts: n/a
 
      6th Mar 2008
Hi All,i got some help with code from this site from Dave and Bob which
works great. I have realised that the workbook i get from Germany has
all the various sheets in the book but some are hidden. I am looking for
the "Qualitaet" sheet which is on all, just it is hidden if you request
the "Tool Tracking" option as an example.


I would like to look for the unhidden sheet, is this possible ? If so
how would i change my code ??

Sub DoesSheetExist()
'
Dim myKTLih As String

myKTLih = "90ZA0810"


If
IfSheetExistsTest("\\nv09002\tpdrive\Projects\General\1700_Management_Re
port\KTL\" _
& myKTLih & ".xls", "Qualitaet") = True Then

MsgBox "The sheet exists"
Else
MsgBox "You have loaded the incorrect KTL", vbOKOnly, "ERROR"
End If

End Sub
'-----------------------------------------------------------------
Function IfSheetExistsTest(FileName As String, sh As String) As Boolean
Dim oConn As Object


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"
IfSheetExistsTest = (Err.Number = 0)

oConn.Close
Set oConn = Nothing

End Function



Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Further to my last thread - Check for worksheet in a closed file Les Stout Microsoft Excel Programming 2 4th Dec 2007 03:22 PM
Check for worksheet in closed workbook Les Microsoft Excel Programming 4 3rd Dec 2007 04:45 PM
GETPIVOTDATA from a closed book =?Utf-8?B?c2VyZ2U=?= Microsoft Excel Discussion 2 5th Nov 2007 01:05 AM
Copy Worksheet from closed book. =?Utf-8?B?U2F1cmp1c2E=?= Microsoft Excel Programming 2 10th Nov 2005 05:49 PM
Open book, check for macros, close book CLR Microsoft Excel Programming 8 31st Mar 2005 06:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:48 AM.