BlueIshDan
☠
- Local time
- Today, 10:42
- Joined
- May 15, 2014
- Messages
- 1,122
If you approve of the way this currently works then please quick post: APPROVE
If you know of a way to improve this then PLEASE DO post your ideas! (PLEASE DO)
Hello, I would like to pass this one by the minds of the more experienced here at this forum!
Could you please read over and try to suggest improvements for efficiency and/or approve that it is good as it currently stands.
This Sub is made to create the directories for the address sent to it:
Starting from the end and working its way back, the script checks to see if the folders currently exist. Once found, it rubber bands forward and begins to create all non-existing folders.
Reference: Micosoft Scripting Runtime
Thanks,
BlueIshDan
Improvements:
Added declaration of i and j Variants for use of Option Explicit
Removed double check of folder existance, since it is checked already.
If you know of a way to improve this then PLEASE DO post your ideas! (PLEASE DO)
Hello, I would like to pass this one by the minds of the more experienced here at this forum!
Could you please read over and try to suggest improvements for efficiency and/or approve that it is good as it currently stands.
This Sub is made to create the directories for the address sent to it:
Starting from the end and working its way back, the script checks to see if the folders currently exist. Once found, it rubber bands forward and begins to create all non-existing folders.
Reference: Micosoft Scripting Runtime
Code:
Public Sub CreateDirectories(ByVal address As String)
' Verify that the address is not a drive.
' You can do this by checking that the length of the address
' is creater than 4
' C:\x\
If Len(address & vbNullString) > 4 Then
Dim fs As New FileSystemObject
Dim var_split As Variant
Dim path As String
If Not fs.FolderExists(address) Then
For Each var_split In Split(address, "\")
path = path & var_split & "\"
If Not fs.FolderExists(path) Then: fs.CreateFolder path
Next
End If
End If
End Sub
Thanks,
BlueIshDan
Improvements:
Added declaration of i and j Variants for use of Option Explicit
Removed double check of folder existance, since it is checked already.
Last edited: