Thread: Parent Folder
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Parent Folder

Hi Bruce,

For xl2k ==, try something like:

'===============
Public Sub Tester02()
Dim strPath As String
Dim strParent As String
Dim pos As Long

strPath = "c:\test\subfolder1\subfolder2"

pos = InStrRev(strPath, "\")

strParent = Left(strPath, pos - 1)

MsgBox strParent

End Sub

'<<===============


---
Regards,
Norman



"Bruce" wrote in message
...
I want to return the parent folder relative to the folder for the current
workbook.

The following get me the path to my workbook such as
c:\test\subfolder1\subfolder2.

Function test()
Dim myString As String
myString = ThisWorkbook.Path
End Function

How can I modify the string to get
c:\test\subfolder1

Bruce