View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Roger Govier[_3_] Roger Govier[_3_] is offline
external usenet poster
 
Posts: 2,480
Default Using Wildcards for Folders

Hi

You could use something like the following
Dim spath As String, lpos As Long

spath = Thisworkbook.Path
lpos = InStrRev(spath, "\")
If Mid(spath, lpos + 1, 2) < "20" Then
MsgBox "Wrong Folder"
End If


--
Regards
Roger Govier

"Orion Cochrane" wrote in message
...
Excel 2003

The following is stored in my PERSONAL.xls file.

I have a module with a series of macros. One of them is a Private Sub that
checks the path of the current workbook and, if the path of the current
workbook doesn't check out with what I have written, the user will get a
warning and the macro will not run. All other macros are public so I can
call
them up with the Macros button, and their first line is to Call Directory
(Directory being the name of the Private Sub with the ActiveWorkbook.Path
line). The last folder of the path is a year. As opposed to manually
changing
the name of the last folder every year, can I use a wildcard (*) to make
it
accept any folder like 20* for the years? The only reason I am asking is
that
my boss has this macro in her PERSONAL.xls (which I set up for her) and
the
project is locked. Here's an example:

Change:
O:\Folder1\2008
to
O:\Folder1\20*

The reason for the Directory sub is that the macros are tailored to
certain
files with the same setup, so it wouldn't work otherwise. Thanks in
advance.
--
Please rate posts so we know when we have answered your questions. Thanks.