Create folders and save Workbook

Siderman

New Member
Joined
Jul 24, 2012
Messages
34
How can i make this code save new folder to "\\fileserver\Users\Public\Documents\Main Customer\New Folder Name"
and create 3 subfolders "Images","Work Orders","Lead Info"
Code:
Public Sub SaveOnDesktop()Dim strPath As String, strFile As String
'Build Path
strPath = Environ$("HOMEPATH") & Application.PathSeparator & "Desktop" & _
Application.PathSeparator & Range("A1").Value
'Make Folder
MkDir strPath
'Build File Name
strFile = strPath & Application.PathSeparator & Range("A1").Value
'Save Activeworkbook
ActiveWorkbook.SaveAs strFile, 52 '51 is for default
End Sub
the current code creates filepath,names workbook,saves workbook all onto users desk top
Any help would be greatly appreciated!!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Code:
Public Sub SaveOnDesktop()
Dim strPath As String, strFile As String
'Build Path
strPath = "\\fileserver\Users\Public\Documents\Main Customer\New Folder Name"
'Make Folder
MkDir strPath
'Build File Name
strFile = strPath & Application.PathSeparator & Range("A1").Value
'Save Activeworkbook
ActiveWorkbook.SaveAs strFile, 52 '51 is for default
End Sub
 
Upvote 0
Thanks patel45 that worked!
I tweeked to to name new folder based on cell value.
Now how do i make subfolders with specific names
I have tried different MkDir & createfolder ect.. with no luck.
 
Upvote 0
This is how i put MkDir strPath & "\" & subfoldername into my code and it didnt work ?
Code:
Public Sub SaveOnDesktop()Dim strPath As String, strFile As String
'Build Path
strPath = "\\fileserver\Users\Public\Documents\Main Customer\Current Job's\" & Range("A1").Value
'Make Folder
MkDir strPath & "\" & subfoldername
'Build File Name
strFile = strPath & Application.PathSeparator & Range("A1").Value
'Save Activeworkbook
ActiveWorkbook.SaveAs strFile, 52 '51 is for default
End Sub
:confused:
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top