Macro - Create new folder and save file into it

f_nnell

New Member
Joined
Sep 27, 2010
Messages
3
Hi, i need a macro that will create a new folder in the users
"my documents" called "BP Upload Tool" and then save the file that that they are working on (the one with the button) to that file with using the the name in cell "F20"

Your help will be greatly appreciated. i managed to get it to save with the file name i want but can not work out how to create the new folder and then save it.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Welcome to the board.

Try the following:
How to change the active station:

ChDrive "F" ' changes to the F-station</PRE>How to change the active folder:

ChDir "F:\My Documents\Private"</PRE>
If you don't specify the station, Excel uses the active station. If you don't specify the folder, Excel uses the active folder. How to create a new folder:
MkDir "NewPrivateFolder" ' creates a new folder in the active folderMkDir "F:\My Documents\NewPrivateFolder"</PRE>
</PRE>
Taken from:</PRE>
http://www.exceltip.com/st/Basic_file_and_folder_examples_using_VBA_in_Microsoft_Excel/443.html</PRE>
</PRE></PRE>
 
Upvote 0
this is the text i have

Public Sub SaveAsA1()
ThisFile = Range("F20").Value
ActiveWorkbook.SaveAs Filename:=ThisFile
End Sub



where would your txt go?
 
Upvote 0
Rich (BB code):
Public Sub SaveAsA1()
ThisFile = Range("F20").Value
MkDir "C:/NewFolder"
ChrDir "C:/NewFolder"
ActiveWorkbook.SaveAs Filename:=ThisFile
End Sub
You may not need the ChrDir part or play around with this as I've not tested it.
 
Upvote 0
I think the slashes are reversed and chrdir shoud be chdir...try this

MkDir "C:\NewFolder"
ChDir "C:\NewFolder"
 
Upvote 0

Forum statistics

Threads
1,214,912
Messages
6,122,200
Members
449,072
Latest member
DW Draft

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