Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Full path without the file name?

Status
Not open for further replies.

knifey

Technical User
Nov 14, 2006
180
GB
Hi,
I have a full path and file name held in a string variable. Is there an easy way to get the full path without the file name?
Maybe outputFileName & .Parent.Name or something similair?
Any advice would be much appreciated.
Thanks,
K
 
In Excel

Dim strPath As String
strPath = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name
 
Code:
MsgBox CreateObject("scripting.filesystemobject").GetParentFolderName(strPathAndFile)
 
If you already have a string with both in then:

strPath = Left(FullPathAndName,instrrev(FullPathAndName,"\"))

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top