Input todays date.

SteveD 745 Reputation points
2026-12-04T00:30:32.9266667+00:00

Hello from Steve

Can the below please also input todays date ie 04-Dec-2026

Sub SaveDocument()

Dim docName As String

docName = Trim(InputBox("Enter the document name:"))

If docName = "" Then Exit Sub

ActiveDocument.SaveAs2 _

    FileName:="C:\Racing\" & docName & ".docx", _

    FileFormat:=wdFormatDocumentDefault

End Sub

Microsoft 365 and Office | Word | For home | Windows
0 comments No comments

Answer accepted by question author

AI answer

2026-12-04T00:31:04.8833333+00:00

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

  1. Format function
  2. Document.SaveAs2 method (Word)
AI-generated content may be incorrect. Read our transparency notes for more information.

Was this answer helpful?

2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Charles Kenyon 172.6K Reputation points Volunteer Moderator
    2026-12-04T03:59:08.6933333+00:00

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.