How to save Word document with current date in filename?

To automatically add the current date to the file name when saving a Word document, follow these steps:

  1. Press ALT + F11 to open the Microsoft Visual Basic for Applications window.
  2. Click on Insert > Module, then copy and paste the following code into the open module:
Public Sub FileSave1()
Dim xDlg As Dialog
Dim xTitle As StringOn Error Resume Next

xTitle = ActiveDocument.BuiltInDocumentProperties(“Title”).Value
xTitle = xTitle & ” ” & Format((Year(Now() + 1) Mod 100), “20##”) & “-” & _
Format((Month(Now() + 1) Mod 100), “0#”) & “-” & _
Format((Day(Now()) Mod 100), “0#”)

Set xDlg = Dialogs(wdDialogFileSaveAs)
xDlg.Name = xTitle
xDlg.Show
End Sub

  1. After pasting the code into the module, press F5 to run the code. The Save As window will automatically appear with the current date in the File Name text box, as shown in the screenshot:

    How to save Word document with current date in filename

    How to save Word document with current date in filename

  2. You can then enter your desired file name and proceed with saving, as illustrated in the screenshot:

By running this VBA code, you’ve created a convenient way to save your Word documents with the current date automatically included in the file name.

We will be happy to hear your thoughts

Leave a reply

Gotkey.net
Logo
Compare items
  • Total (0)
Compare
0
Shopping cart