1. 按住 ALT + F11 鍵,即可開啟 Microsoft Visual Basic for Applications 視窗!
2. 接著,點選插入> 模組,並將下方程式碼複製貼上至開啟的空白模組中:
VBA 程式碼:將 Word 文件以包含當前日期的檔名儲存
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