TTom
Well-known Member
- Joined
- Jan 19, 2005
- Messages
- 518
I'm using UDF below with Procedure to determine if WB is open; however, I want to check if ANY WB ending in:
"_TimeCard-Status_MASTER" is open. The WB being checked will always be in the name format:
YYYY-##_TimeCard-Status_MASTER
So, I want to ignore the left 7 characters of WB name when checking if a WB ending in "_TimeCard-Status_MASTER" is open.
I need help to modify my UDF or Procedure. See the line defining BName in my procedure.
Thanks for any help :wink: TTom
<code>
Dim myWbk As Boolean
Public Function IsBookOpen(BName As String) As Boolean
Dim WBk As Workbook
On Error Resume Next
If InStr(1, BName, ".xls", 1) = 0 Then BName = BName & ".xls"
Set WBk = Workbooks(BName)
IsBookOpen = (Err = 0) + 0
myWbk = IsBookOpen
End Function
Sub myWBopen()
BName = "-Status_MASTER" 'This is not complete WB name!!
IsBookOpen (BName)
If myWbk = True Then
MsgBox ("WB is Open")
Else:
MsgBox ("WB is Closed")
End If
End Sub
</code>
"_TimeCard-Status_MASTER" is open. The WB being checked will always be in the name format:
YYYY-##_TimeCard-Status_MASTER
So, I want to ignore the left 7 characters of WB name when checking if a WB ending in "_TimeCard-Status_MASTER" is open.
I need help to modify my UDF or Procedure. See the line defining BName in my procedure.
Thanks for any help :wink: TTom
<code>
Dim myWbk As Boolean
Public Function IsBookOpen(BName As String) As Boolean
Dim WBk As Workbook
On Error Resume Next
If InStr(1, BName, ".xls", 1) = 0 Then BName = BName & ".xls"
Set WBk = Workbooks(BName)
IsBookOpen = (Err = 0) + 0
myWbk = IsBookOpen
End Function
Sub myWBopen()
BName = "-Status_MASTER" 'This is not complete WB name!!
IsBookOpen (BName)
If myWbk = True Then
MsgBox ("WB is Open")
Else:
MsgBox ("WB is Closed")
End If
End Sub
</code>