I have a file called Parts On BackOrder-093022.xlsm. The beginning is always the same Parts On BackOrder
In the Below Code I have a Function that checks to see if a workbook is open. The function works great if looking for the whole workbook name. But how do I modify it for checking for a partial name that begins with Parts On BackOrder
Thank You!!!
In the Below Code I have a Function that checks to see if a workbook is open. The function works great if looking for the whole workbook name. But how do I modify it for checking for a partial name that begins with Parts On BackOrder
Thank You!!!
VBA Code:
Function IsWorkBookOpen(Name As String) As Boolean
Dim xWb As Workbook
On Error Resume Next
Set xWb = Application.Workbooks.Item(Name)
IsWorkBookOpen = (Not xWb Is Nothing)
End Function
Sub CheckWorkBook()
Dim xRet As Boolean
xRet = IsWorkBookOpen("Parts On BackOrder-093022.xlsm") '<----How do I change this?
If xRet Then
ActiveWorkbook.Save
ActiveWorkbook.Close
Else
MsgBox "Parts On Backorder Is Already Closed",vbExclamation
End If
End Sub