Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Using wildcard for checking whether files are open

Try

If wkbk.Name Like "something*" Then


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



wrote in message ...
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



Reply
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
how do I toggle between 2 open excel files and leave both open Big D in Brighton Excel Discussion (Misc queries) 1 November 6th 08 04:28 PM
How to change default Open/Files of Type to "Microsoft Excel Files Tammy Excel Discussion (Misc queries) 2 January 14th 08 11:06 PM
using wildcard characters for filenames in externally linked files Harold Good Excel Discussion (Misc queries) 0 June 27th 06 03:40 AM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven Excel Discussion (Misc queries) 1 January 24th 06 03:28 PM
file open via IE hyperlink causes already open files to shrink and tile Marc Setting up and Configuration of Excel 0 May 4th 05 08:13 PM


All times are GMT +1. The time now is 01:13 PM.

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

About Us

"It's about Microsoft Excel"