Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default 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
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
Creating a macro that lists directory names within a directory.... Andy Excel Programming 4 November 28th 04 06:13 AM
MultiPage Parent Name John Wilson Excel Programming 4 November 19th 04 02:42 PM
Check if directory empty OR no of files in directory. Michael Beckinsale Excel Programming 2 December 4th 03 10:12 PM
How does Excel determine the TEMP directory? Miso Excel Programming 3 July 31st 03 02:19 PM


All times are GMT +1. The time now is 04:34 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"