Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Parent of the embeded excel ARHangel Excel Discussion (Misc queries) 1 May 10th 07 11:19 AM
A parent spreedsheet problem workaholic Excel Discussion (Misc queries) 9 November 6th 05 07:35 PM
How to determine the parent directory KS Wong[_2_] Excel Programming 5 May 6th 05 02:27 AM
finding the parent row of a cell in VBA Andrew Marshall Excel Programming 2 January 18th 05 12:05 PM
MultiPage Parent Name John Wilson Excel Programming 4 November 19th 04 02:42 PM


All times are GMT +1. The time now is 09:00 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"