View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] vbmonique@hotmail.com is offline
external usenet poster
 
Posts: 1
Default Using wildcard for checking whether files are open

I have macros that are used by several files.
One of the macros creates the toolbar, then I have a Closebook macro
that checks whether how many files are still open.
When the last file is being closed, the macro deletes the toolbar.

I am starting to have more files that need to be checked and I am
wondering if there is a way to put a wildcard in the checking of the
name. For example, if workbook name is Price List*.xls then ....

Here's the code that I currently have -

Count = 0
ListName = "Price List - "

For Each wkbk In Application.Workbooks
If wkbk.Name = ListName & "Central.xls" Then
Count = Count + 1
End If

If wkbk.Name = ListName & "Eastern.xls" Then
Count = Count + 1
End If

If wkbk.Name = ListName & "Western.xls" Then
Count = Count + 1
End If

Next

If Count <= 1 Then
On Error Resume Next
Application.CommandBars("Price List").Delete

End If


Thanks for your help.

Monique