Jump to Real's How-to Main page

Create unique folder name

The folder name will be based on the current date and time.
Option Explicit

Dim objFSO, dNow, yy, mt, dd, hh, nn, ss, NewFolder
Set objFSO = CreateObject("Scripting.FileSystemObject")

dNow = Now
yy = Right(Year(dNow), 2)
mt = Right("00" & Month(dNow), 2)
dd = Right("00" & Day(dNow), 2)
hh = Right("00" & Hour(dNow), 2)
nn = Right("00" & Minute(dNow), 2)
ss = Right("00" & Second(dNow), 2)

NewFolder = "c:\" & yy & mt & dd & hh & nn & ss

'Create the folder
objFSO.CreateFolder NewFolder

If you find this article useful, consider making a small donation
to show your supportfor this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2005
[ home ]