Remove File Path - just keep name

  • Thread starter Thread starter Ski
  • Start date Start date
S

Ski

I have a file name that includes the entire file path, file name, and
extension:

C:\Documents and Settings\Desktop\Master Schedules\Overall IMS -
26May2006.mpp

I need some code to shorten that to just:

Overall IMS - 26May2006.mpp

I can't just type it in because the file is different each time, based
on user input.

Thanks in advance
 
ShortFileName = Right(LongFileName,Len(LongFileName) - _
InStrSev(LongFileName, Application.PathSeparator))

HTH

Charles Chickering
 
InStrSev
should be
InStrRev

And this will work in xl2k and above (InStrRev was added in xl2k).
 
Doh! I hate typos. Oh well, I guess that's what you get when you wing
stuff instead writing it in the editor. How long has the
Application.PathSeparator been around? I just included that to make it
Mac friendly as well, is that going to be a problem in earlier
versions?

Charles
 
I believe it was there in xl95.

(I actually used to use it until I got too lazy! And we were a WinTel only
shop.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top