VBA creating new folders and files
Hello all,
I'm very new here. I have some VBA knowledge but not much. Usually I search and edit codes to fit my needs, but this time I'm stuck and could use some advice.
Here is what I'm looking to accomplish with my code.
I currently have a code that creates folders and sub folders using cell value as main folder name. I would like within this same code, to be able to Save As one of the sheets as a new file in one of the newly created sub folders.
Below is the code I'm using. Works fine and does everything it needs to do.
I have a tab/sheet named "Test Plan" to be saved under sub folder "Test Info" with the vehicle number from "B1" as name. If its possible to have TP before or after the vehicle number in the name, would be even better. example TP BY1111242.xls or BY1111242 TP.xls
For some reason, I'm denied to post an excel screen shot.
Thank you very much!
Code:
Sub MakeFolder()
Dim strVehNum As String, strPathDefault As String, strFolderTestInfo As String, strFolderPics As String, strFolderServiceComments As String, strFolderPrintouts As String
Dim FSO As New FileSystemObject
strVehNum = Range("B1") ' assumes vehicle number in B1
strPath = "G:\03 PROJECTS\AUTOS"
strFolderTestInfo = "Test info"
strFolderPics = "Pics"
strFolderServiceComments = "Service comments"
strFolderPrintouts = "Printouts"
If Not FSO.FolderExists(strPath & strVehNum) Then
FSO.CreateFolder strPath & strVehNum
FSO.CreateFolder strPath & strVehNum & "" & strFolderTestInfo
FSO.CreateFolder strPath & strVehNum & "" & strFolderPics
FSO.CreateFolder strPath & strVehNum & "" & strFolderServiceComments
FSO.CreateFolder strPath & strVehNum & "" & strFolderPrintouts
Else
End If
UserName
End Sub