View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_14_] Bob Phillips[_14_] is offline
external usenet poster
 
Posts: 216
Default quick help: get folder name

With ActiveWorkbook
iPos = InStrRev(.Path, "\")
If iPos 1 Then
sFolder = Right(.Path, Len(.Path) - iPos)
Else
iPos = InStrRev(.Path, ":")
End If
If iPos 1 Then sFolder = Right(.Path, Len(.Path) - iPos)
End With

MsgBox sFolder


--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"yo" wrote in message
oups.com...
hi, i'm a n00b on vba, can somebody tell me how to get (extract) the
folder name from ActiveWorkbook.Path? i read about InStr() &
InStrRev(), but i don't know how to use the result from InStr (as i
find below), and InStrRev i can't make sense of (returns 10 from
comparing "D:\BACKUP\myjobprices\tmp" with "\", and 0 if starts at 1)

so i got a macro from this group, but instead of extract the folder
name, it returns the root & parent folder name/path. so instead of
"tmp", i got "D:\BACKUP\myjobprices"

here's where i got the function:

http://groups.google.com/group/micro...4f416e2bef2ee8

any help will be great. i may try another route, since there's a date
entry inside the file, which will be combined with another data
(job/project name) for duplicating the file inside a new folder name.
but i want to exhaust this option first. thanks