0
Thanks

A few words of thanks would be greatly appreciated.

Excel VBA - A button to save a copy of current file

Issue


I am looking for a way to include an automatic record button in an Excel spreadsheet. This button would automatically save a copy of the current sheet in a given directory by adding to the original file name the date and time, e.g "my_file_24102007_0830.xls"

Solution


Public Sub CommandButton1_Click()  
Dim nom As String 
    nom = Day(Date) & "-" & Month(Date) & "-" & Year(Date) & "_" & ActiveWorkbook.Name 
    ActiveWorkbook.SaveCopyAs ActiveWorkbook.Path & "\" & nom 
    rep = MsgBox("You database has been saved : " & name, vbYes + vbInformation, "Copy of spreadsheet") 
End Sub


Thanks to gbinforme for this tip
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Related

This document, titled « Excel VBA - A button to save a copy of current file », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).

0 Comments