Saving File With today's Date

mrtim2232

New Member
Joined
Aug 24, 2017
Messages
48
Morning all,

I created this macro to save my file to a specific folder and use todays date within the file name and it worked great in my test spreadsheet but when I tried to transfer the code across to my user spreadsheet it returns a problem which is. compile error: wrong number of arguments or invalid property assignment. I have pasted a copy of the code below. Any help on this issue would be appreciated.

Sub filesave()
ActiveWorkbook.SaveAs ("C:\Users" & Environ("username") & _
"\downloads\Saved Data\data" & Format(Now(), "DD-MM-YY hh mm AMPM") & ".xlsm")
End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Try This

Code:
Sub filesave()
ActiveWorkbook.SaveAs "C:\Users" & Environ("username") & _
"\downloads\Saved Data\data" & Format(Now(), "DD-MM-YY hh mm AMPM") & ".xlsm", xlOpenXMLWorkbookMacroEnabled
End Sub
 
Upvote 0
Not sure if this is the problem, but you're missing a \ after users.
It may however have been stripped out the software.
 
Last edited:
Upvote 0
Not sure if this is the problem, but you're missing a \ after users.
It may however have been stripped out the software.


Also missing after data :

Code:
"\downloads\Saved Data\data\"
 
Upvote 0
Hi All,

Thanks for your help so far I have tried your suggestions and although its cleared it up a bit I'm still stuck with the original error and when I debug this error it highlights the "format" part of the code. For some reason it works on my trial sheet and even works if I run the trail macro on my running sheet.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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