View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Mike Fogleman Mike Fogleman is offline
external usenet poster
 
Posts: 1,092
Default FileDialog Question

Glad to help. Notice that this works on all extension lengths.

Mike F
"LeAnn" wrote in message
...
Very nice - worked perfectly. Didn't know about InStrRev - was thinking
there should be something like that.


"Mike Fogleman" wrote:

Sub test()
Dim PName As String, FName As String
Dim i As Long, Dot As Long

PName = "C:\RootFolder\SubFolder\MyBook.xls" 'full path
i = InStrRev(PName, "\") + 1 'position of last "\"
Dot = InStrRev(PName, ".")
FName = Mid(PName, i, Dot - i)
End Sub

Mike F
"LeAnn" wrote in message
...
Hi,

I have a follow up question to my earlier post - using Excel 2003. I
am
able to set the default directory for the user to choose a single file
from.
However, I need to extract the actual filename from the path (excluding
the
extension).

Is there a property that does this? I haven't see anything so far.
The
file name length may be variable so my attempt at using a combination
of
Left
and Right functions didn't always work.

Any ideas?

Thanks
LeAnn