Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to determine the parent directory
Dear all,
I have a string variable, i.e. strDB="c:\data\aproject\database\dbfile.mdb". I want to add a subdirectory under "c:\data\aproject\reports" programmatically. How can I do that? Thanks in advance! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to determine the parent directory
strDB = "c:\data\aproject\database\dbfile.mdb"
iPos = InStrRev(strDB, "\") iPos = InStrRev(strDB, "\", iPos - 1) MkDir Left(strDB, iPos) & "reports" -- HTH Bob Phillips "KS Wong" wrote in message ... Dear all, I have a string variable, i.e. strDB="c:\data\aproject\database\dbfile.mdb". I want to add a subdirectory under "c:\data\aproject\reports" programmatically. How can I do that? Thanks in advance! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to determine the parent directory
Check out this link...
http://support.microsoft.com/default...b;en-us;213800 So use something like Shell ("Command.com /c md C:\Test") HTH "KS Wong" wrote: Dear all, I have a string variable, i.e. strDB="c:\data\aproject\database\dbfile.mdb". I want to add a subdirectory under "c:\data\aproject\reports" programmatically. How can I do that? Thanks in advance! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to determine the parent directory
Nice... I've been creating directories the hard way...
"Bob Phillips" wrote: strDB = "c:\data\aproject\database\dbfile.mdb" iPos = InStrRev(strDB, "\") iPos = InStrRev(strDB, "\", iPos - 1) MkDir Left(strDB, iPos) & "reports" -- HTH Bob Phillips "KS Wong" wrote in message ... Dear all, I have a string variable, i.e. strDB="c:\data\aproject\database\dbfile.mdb". I want to add a subdirectory under "c:\data\aproject\reports" programmatically. How can I do that? Thanks in advance! |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to determine the parent directory
Here are two additional ideas:
Sub Demo1() Dim v Dim s As String Const strDB = "c:\data\aproject\database\dbfile.mdb" v = Split(strDB, Application.PathSeparator) v(UBound(v)) = "Reports" s = Join(v, Application.PathSeparator) End Sub Sub Demo2() Dim fso Dim s As String Const strDB = "c:\data\aproject\database\dbfile.mdb" Set fso = CreateObject("Scripting.FileSystemObject") With fso If .FileExists(strDB) Then s = .BuildPath(.GetFile(strDB).ParentFolder.Path, "Reports") End If End With End Sub HTH :) -- Dana DeLouis Win XP & Office 2003 "KS Wong" wrote in message ... Dear all, I have a string variable, i.e. strDB="c:\data\aproject\database\dbfile.mdb". I want to add a subdirectory under "c:\data\aproject\reports" programmatically. How can I do that? Thanks in advance! |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to determine the parent directory
Thank you very much all of you!
"Dana DeLouis" wrote: Here are two additional ideas: Sub Demo1() Dim v Dim s As String Const strDB = "c:\data\aproject\database\dbfile.mdb" v = Split(strDB, Application.PathSeparator) v(UBound(v)) = "Reports" s = Join(v, Application.PathSeparator) End Sub Sub Demo2() Dim fso Dim s As String Const strDB = "c:\data\aproject\database\dbfile.mdb" Set fso = CreateObject("Scripting.FileSystemObject") With fso If .FileExists(strDB) Then s = .BuildPath(.GetFile(strDB).ParentFolder.Path, "Reports") End If End With End Sub HTH :) -- Dana DeLouis Win XP & Office 2003 "KS Wong" wrote in message ... Dear all, I have a string variable, i.e. strDB="c:\data\aproject\database\dbfile.mdb". I want to add a subdirectory under "c:\data\aproject\reports" programmatically. How can I do that? Thanks in advance! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Parent of the embeded excel | Excel Discussion (Misc queries) | |||
Creating a macro that lists directory names within a directory.... | Excel Programming | |||
MultiPage Parent Name | Excel Programming | |||
Check if directory empty OR no of files in directory. | Excel Programming | |||
How does Excel determine the TEMP directory? | Excel Programming |