![]() |
Parent Folder
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 |
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 |
Parent Folder
Depending on what you're doing, you could just use:
ThisWorkbook.Path & "\.." to get to the parent directory. (But this'll have trouble if you're in the root folder.) Bruce wrote: 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 -- Dave Peterson |
All times are GMT +1. The time now is 10:16 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com