Skip to main content

How to save Word document with current date in filename?

Author: Xiaoyang Last Modified: 2018-11-14

If you need to add the current date in filename automatically when saving a Word document, how could you deal with this task in Word file?

Save a Word document with current date in filename with VBA code


Save a Word document with current date in filename with VBA code

To automatically add the current date into the filename when saving the Word document, please do with the following steps:

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. And then, click Insert > Module, copy and paste below code into the opened blank module:

VBA code: Save a Word document with current date in filename

Public Sub FileSave1()
    Dim xDlg As Dialog
    Dim xTitle As String
    On 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

3. After pasting the code into the module, press F5 key to run this code, and a Save As window is displayed with the current date automatically into the File name text box, see screenshot:

doc save with date 1

4. And then, you just need to type your own file name as you need, see screenshot:

doc save with date 2

Best Office Productivity Tools

Kutools for Word - Elevate Your Word Experience with Over 100 Remarkable Features!

๐Ÿค– Kutools AI Assistant: Transform your writing with AI - Generate Content  /  Rewrite Text  /  Summarize Documents  /  Get Quick Answers, all within Word

๐Ÿ“˜ Document Mastery: Split Pages  /  Merge Documents  /  Export Selection in Various Formats (PDF/TXT/DOC/HTML...)  /  Batch Convert to PDF  /  Export Pages as Images  /  Print Multiple Files at once...

โœ Contents Editing: Batch Find and Replace across Multiple Files  /  Resize All Pictures  /  Transpose Table Rows and Columns  /  Convert Table to Text...

๐Ÿงน Effortless Clean: Sweap away Extra Spaces  /  Section Breaks  /  All Headers  /  Text Boxes  /  Hyperlinks  /  For more removing tools, head to the Remove group...

โž• Creative Inserts: Insert Thousand Separators  /  Check Boxes  /  Radio Buttons  /  QR Code  /  Barcode  /  Diagonal Line Table  /  Equation Caption  /  Image Caption  /  Table Caption  /  Multiple Pictures  /  Discover more in the Insert group...

๐Ÿ” Precision Selections: Pinpoint Specific Pages  /  Tables  /  Shapes  /  Heading Paragraphs  /  Enhance navigation with more Select features...

โญ Star Enhancements: Navigate to Any Location  /  Auto-Insert Repetitive Text  /  Toggle Between Document Windows  /  11 Conversion Tools...

๐Ÿ‘‰ Want to try these features? Download Kutools for Word now! ๐Ÿš€
 
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations