Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make a directory named the current date

Status
Not open for further replies.

shagymoe

Programmer
Apr 20, 2001
72
US
I'm a beginner, and I'm sure this is simple, but I can't figure it out. The code below just names the folder TodayDate.

Private Sub cmdMkDir_Click()
Dim TodayDate As Date
TodayDate = Date
MkDir "c:\Todaydate"
End Sub

Any ideas on how to get it to do this?
 
Code:
'------------------------------
'Long Method
'------------------------------
Dim sToday As String
Dim sPath As String

sToday = Format(Now, "mm-dd-yy")

sPath = "C:\" & sToday

MkDir sPath

'------------------------------
'Short Method
'------------------------------
MkDir "C:\" & Format(Now, "mm-dd-yy")
Hope this helps
 
Actually neither worked. But I see your logic. Maybe I am doing something wrong, but it doesn't like the MkDir line:

I think it is because it doesn't understand the code after the last "

Like it doesn't know what to do with the & sToday or & Format.........
 
My bad!!! It didn't like something else in my path.
One of the folders is named "g out" with a space between the g and out.
It didn't like that at all.
hmmmmm.....anyone know how to fix that other than naming it something else?
This directory is used in other programs, so I can't change it.
 
Dim MyDir As String
MyDir = Format(Date, "dd-mm-yy")
MkDir "c:\" & MyDir

The above puts a folder in the root directory on my computer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top