Hi guys,
I am currently using this code to get the folder name (fourth) containing the current drawing.
FolderName = Dir(ThisDrawing.path, vbDirectory)
What would I use if I wanted to get the foldername one level up (third)?
ex. C:\FIRST\SECOND\THIRD\FOURTH
Any help is greatly appreciated.
Shawn
Hi,
use function SPLIT (>>>details<<<) with "\" as separator to get an array of directories building up the path.
Remove the last item of that array.
Use function JOIN (>>>details<<<) to create a string of this array.
- alfred -
I will explore that, I'm not fluent in coding, Will that work if the folder one level up is not always the same? Basically I am trying to take a folder name that is one level up from the parent folder and put it into a titleblock. The code
FolderName = Dir(ThisDrawing.path, vbDirectory)
allows me to grab the name of the file's parent folder whatever name that may be and put it into the drawing titleblock.
Thanks for all of the help.
As [alfred.neswadba] said you can use Split() function to get previous folders from full path. The code is in .NET but I think in VBA is similar to this:
string path=@"C:\FIRST\SECOND\THIRD\FOURTH";
string[] wtf = path.Split('\\');
string first = wtf[0]; // first = c:
string second = wtf[0] + "\\" + wtf[1]; // second = "c:\\FIRST"
............