Creating Directory Structure from Cell Value
Hi
I think you can try this-
Dim Fldr As Scripting.FileSystemObject
Dim mMyDir as String
mMyDir=Format(Range("D2").Value,
"YYYY") & "\" & Format(Range("D2").Value, "mm") & " " &
Format(Range("D2").Value, "MMMM") &"\" & Format(Range("D2").Value,
"dd")
Set Fldr = New Scripting.FileSystemObject
If Fldr.FolderExists("C:\Reports\"&mMyDir) Then
Else
Fldr.CreateFolder "C:\Reports\"&mMyDir
End If
HTH,
--
Pranav Vaidya
VBA Developer
PN, MH-India
If you think my answer is useful, please rate this post as an ANSWER!!
" wrote:
I previously posted this to the incorrect group. Sorry about that.
I was able to create a partial structure from information in a
previous post.
Post Follows:
From user: Farhad
Dim Fldr As Scripting.FileSystemObject
Set Fldr = New Scripting.FileSystemObject
If Fldr.FolderExists("C:\Reports\2007-09-18") Then
Else
Fldr.CreateFolder "C:\Reports\2007-09-18"
End If
make sure you have referred to MicroSoft Scripting Runtime from
ToolsReferences
Thanks,
--
Farhad Hodjat
Question:
Assuming that the value of Cell D2 is a date in the format 12/2/07
18:39.
I would like to create the following file structure from that
information
Drive:\Place Where Data is Stored\Year\Month (two digit) Month
(Verbal)
\Day (two digit)
So with the data from Cell D2 it would look like this:
Drive:\Place Where Data is Stored\2007\12 December\02\
I have used the following adjustment to the data and can't seem to
get
the full file structure.
"Drive:\Place Where Data is Stored\" & Format(Range("D2").Value,
"YYYY") & "\" & Format(Range("D2").Value, "mm") & " " &
Format(Range("D2").Value, "MMMM") &"\" & Format(Range("D2").Value,
"dd")
With the previous formula I either get an error or nothing happens at
all or I get a directory structure like this "Drive:\Place Where Data
is Stored\200711\ or Drive:\Place Where Data is Stored\200711November
\. The workbook where the data is contained is the active workbook.
|