I have snipped this code for use as part of an export task in excel.
The problem is to make the reference to the actual folder in a later query, what will the relative path to the last created folder be?
Code:
Sub makebackupfolder()
'create reference for file system object
Set fs = CreateObject("Scripting.FileSystemObject")
folderpath = "c:\Users\kdr\Documents\IDS\P01\"
'Check folder name "Export" in folderpath
If fs.FolderExists(folderpath & "\Export\") = True Then
If fs.FolderExists(folderpath & "\Export\" & Replace(Format(Now(), "dd/MM/yyyy_Hh/Nn"), "/", "_")) = True Then
Exit Sub
Else
fs.createfolder folderpath & "\Export\" & Replace(Format(Now(), "dd/MM/yyyy_Hh/Nn"), "/", "_")
End If
Else
'if log folder missing then create it
fs.createfolder folderpath & "\Export\"
fs.createfolder folderpath & "\Export\" & Replace(Format(Now(), "dd/MM/yyyy_Hh/Nn"), "/", "_")
End If
End Sub
Thanks!
KD
The problem is to make the reference to the actual folder in a later query, what will the relative path to the last created folder be?
Code:
Sub makebackupfolder()
'create reference for file system object
Set fs = CreateObject("Scripting.FileSystemObject")
folderpath = "c:\Users\kdr\Documents\IDS\P01\"
'Check folder name "Export" in folderpath
If fs.FolderExists(folderpath & "\Export\") = True Then
If fs.FolderExists(folderpath & "\Export\" & Replace(Format(Now(), "dd/MM/yyyy_Hh/Nn"), "/", "_")) = True Then
Exit Sub
Else
fs.createfolder folderpath & "\Export\" & Replace(Format(Now(), "dd/MM/yyyy_Hh/Nn"), "/", "_")
End If
Else
'if log folder missing then create it
fs.createfolder folderpath & "\Export\"
fs.createfolder folderpath & "\Export\" & Replace(Format(Now(), "dd/MM/yyyy_Hh/Nn"), "/", "_")
End If
End Sub
Thanks!
KD