PDA

View Full Version : [SOLVED:] Getting a Word Doc to save itself with today's date in the file name



delialli
07-31-2018, 09:02 AM
Good afternoon,

I would like users to be able to open a generic word document and trigger a macro which would automatically save the file with today's date, so there's a copy of the file for each day which can be referred back to later.

I have recorded a macro which does the saving (below), but I don't know how to get it to use today's date as the file name.

Any help gratefully received



Sub SaveAs()
'
' SaveAs Macro
'
'
ChangeFileOpenDirectory _
"\\SB1VMHOM02\home$\OveryA\Desktop\SCSM (file://\\SB1VMHOM02\home$\OveryA\Desktop\SCSM) Report\Reports"
ActiveDocument.SaveAs2 FileName:= _
"\\SB1VMHOM02\home$\OveryA\Desktop\SCSM (file://\\SB1VMHOM02\home$\OveryA\Desktop\SCSM) Report\Reports\2017-07-31.docm", _
FileFormat:=wdFormatXMLDocumentMacroEnabled, LockComments:=False, _
Password:="", AddToRecentFiles:=True, WritePassword:="", _
ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False, CompatibilityMode:=14
End Sub

gmaxey
07-31-2018, 09:20 AM
See if this change works:

"\\SB1VMHOM02\home$\OveryA\Desktop\SCSM (file://\\SB1VMHOM02\home$\OveryA\Desktop\SCSM) Report\Reports" & Format(Now, "YYYY-MM-DD") & ".docm", _

delialli
08-01-2018, 01:57 AM
See if this change works:

"\\SB1VMHOM02\home$\OveryA\Desktop\SCSM (file://\\SB1VMHOM02\home$\OveryA\Desktop\SCSM) Report\Reports" & Format(Now, "YYYY-MM-DD") & ".docm", _

It works!!!! Thank you ever so much.