Hi All,
I try to create a subfolder contain following information:
C:\Test\userIDDateTime
Can someone help me below is my code.
Dim oFSO
Dim Retry
Dim PFolder
Dim Pname
Dim FMain
Dim oMain
'Getting Project folder name exist on C drive.
Checkproject (filename)
Function Checkproject (filename)
Dim strRoot
strRoot = "C:\Test"
Set oFSO = CreateObject ("Scripting.FileSystemObject")
'Pname = Inputbox ("Please Enter Your Project Name")
If oFSO.FolderExists (strRoot) Then
Msgbox (strRoot)
Get_User_ID
Get_Date
Get_Time
MakeDir (strPath)
Else
Msgbox ("Please contact your QA or BA to create a project folder name")
End If
End Function
'Get User Initial
Function Get_User_ID
Dim Get_ID
Get_ID = Inputbox ("Please Enter your name initial")
If Get_ID = "" Then
Msgbox ("Initial can not leave blank, please re-enter your initial again")
Get_User_ID
End If
End Function
'Getting Date And Time.
Function Get_Date
Dim MyDate
Dim Short_Date
Dim strDate
MyDate = Date
Short_Date = (Right("00" & Month(Date()),2) & Right("00"&Day(Date()),2) & Right("00"&Year(Date()),2))
'Msgbox ("Your New date is:" & strDate)
End Function
Function Get_Time
Dim MyTime
Dim Short_Time
Dim strTime
MyTime = Time
Short_Time = (Right("00" & Hour(Time()),2) & Right("00"&Minute(Time()),2))
'strTime = Cstr (Short_Time)
'Msgbox ("Your New Time is:" & strTime)
End Function
Function MakeDir (strPath)
Dim strParentPath, objFSO
strPath = Cstr (strRoot & "/" & Get_ID & Short_Date & Short_Time)
Set objFSO = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
strParentPath = objFSO.GetParentFolderName(strPath)
If Not objFSO.FolderExists(strParentPath) Then MakeDir strParentPath
If Not objFSO.FolderExists(strPath) Then objFSO.CreateFolder(strPath)
On Error Goto 0
MakeDir = objFSO.FolderExists(strPath)
End Function
|