View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Return file from a path string

One way Steph

Dim sFile
Dim ary

sFile = "C:\folder1\folder2\folder3\folder4\folder5\file.x ls"

ary = Split(sFile, "\")
MsgBox ary(UBound(ary))

or more directly, but less efficiently

Dim sFile

sFile = "C:\folder1\folder2\folder3\folder4\folder5\file.x ls"
MsgBox Split(sFile, "\")(UBound(Split(sFile, "\")))


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Steph" wrote in message
...
I have a string variable that is a path to a file:
C:\folder1\folder2\folder3\folder4\folder5\file.xl s

How can I create a new variable that is simply the file name.xls? Thanks!