Brain fart - extracting file name from string

twoplustwo

Registered User.
Local time
Today, 07:25
Joined
Oct 31, 2007
Messages
507
Hi all,

I have this string:

S:\DirectSupply\FinanceReporting\Pricing\Models\Tradebook CSV\WCI00P18.csv

I need to extract the WCI00P18 part.

This is liable to change in length. I've apparently forgotten how to use string functions as of late :rolleyes:
 
Use
Mid(string,InStrRev(String,"\")+1)

By using InStrRev is reads from right to left looking for the first instance of the slash. so everything after the slash is returned by using the Mid() command.

BTW can you rephrase your questions in future without the swear words.

David
 
Thanks DC.

Swear words?
 
Hi

I reckon it might be the "F" word mate

Nidge
 
You can also use the 'GetBaseName' method of the Scripting.FileSystemObject, which drops the extension too...
Code:
With CreateObject("Scripting.FileSystemObject")
  Debug.Print .GetBaseName("S:\DirectSupply\FinanceRep...book CSV\WCI00P18.csv")
End With
FSO provides a bunch of methods for working with names
 

Users who are viewing this thread

Back
Top Bottom