Saving to a different name

craigwojo

Active Member
Joined
Jan 7, 2005
Messages
257
Office Version
  1. 365
Platform
  1. Windows
Hi everyone,

I have a button that I would like to put a macro on. The macro should be able to do the following:

Save the name of the file as the current date & time and put the file in the "My Documents" folder. ie. the file would be saved in the My Documents folder as 2006Sept22_10.10.40.xls.

Thank you,
Craig
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi Craig,

Firstly you cannot include ":" as part of the file name, that character isn't accepted. So I've removed it from the file name generator. You may also need to change the file path location in the Filename:= bit. Code as follows:

Code:
Sub Temp()

Dim flName As String

    flName = Format(Now, "yyyymmmdd_hhmmss") & ".xls"

ActiveWorkbook.SaveAs Filename:="C:\Documents and Settings\My Documents\" & flName

End Sub

To assign to a button go to View->Toolbars->Forms. Place a command button on the sheet, right click it and assign it this macro.

Hope this helps.

:)
 
Upvote 0

Forum statistics

Threads
1,216,100
Messages
6,128,824
Members
449,470
Latest member
Subhash Chand

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