LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Ascertaining the directory name (2 levels up)

Hi all

I am using John Walkenbach's code to find the file name only from a
full path string. My structure is as follows:

PARENT_DIR
|
SUB_DIRECTORY
|
ThisWorkbook

I wish to ascertain the parent directory name. I have working code
(below) but am wondering if there's a simpler way to achieve this:
Dim sInitPath As String
Dim sNewPath As String
Dim sParentDir as string


sInitPath = CurDir
sNewPath = ThisWorkbook.Path & "\..\"

ChDrive sNewPath
ChDir sNewPath

sParentDir = FileNameOnly(CurDir)

ChDrive sInitPath
ChDir sInitPath

Thanks in advance

Paul Martin
Melbourne, Australia

 
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
Ascertaining whether external data sources or hyperlinks exist Paul Martin Excel Discussion (Misc queries) 3 June 20th 06 04:55 AM
sum sub levels. Jerome Excel Discussion (Misc queries) 5 April 2nd 06 03:24 AM
open in old directory save in new directory tim64[_2_] Excel Programming 0 June 15th 05 07:48 PM
Creating a macro that lists directory names within a directory.... Andy Excel Programming 4 November 28th 04 06:13 AM
Check if directory empty OR no of files in directory. Michael Beckinsale Excel Programming 2 December 4th 03 10:12 PM


All times are GMT +1. The time now is 05:57 PM.

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

About Us

"It's about Microsoft Excel"