A family of Microsoft word processing software products for creating web, email, and print documents.
Append Format(Date, "dd-mmm-yyyy") to docName when constructing the filename.
Sub SaveDocument()
Dim docName As String
Dim fileName As String
docName = Trim(InputBox("Enter the document name:"))
If docName = "" Then Exit Sub
fileName = "C:\Racing\" & docName & " " & _
Format(Date, "dd-mmm-yyyy") & ".docx"
ActiveDocument.SaveAs2 _
FileName:=fileName, _
FileFormat:=wdFormatDocumentDefault
End Sub
For example, if you enter Racebase, the document will be saved as:
C:\Racing\Racebase 04-Dec-2026.docx
Date supplies the computer’s current date, while dd-mmm-yyyy produces the requested format: two-digit day, abbreviated month, and four-digit year.^1^
Be aware that SaveAs2 overwrites an existing file with the same name without prompting.^2^
References