|
|
|
|
|
|
Word
|
Save Document with Date on Close
|
|
Ease of Use
|
Intermediate
|
Version tested with
|
2000
|
Submitted by:
|
Graham Skan
|
Description:
|
When you close a document with this macro in it, it saves the file with a specified name, followed by the date in whatever format you choose.
|
Discussion:
|
Suppose you must fill out the same form every day; perhaps a daily log of what you worked on that day, or some other type of diary. You can put this macro in your document, and when you close the document, it'll automatically save it with a specified name, followed by a date format that you can specify.
|
Code:
|
instructions for use
|
Private Sub Document_Close()
Dim FileName As String
FileName = "LogID" & Format(Now, "mm-dd-yy")
ActiveDocument.SaveAs FileName
End Sub
|
How to use:
|
- Copy the code above.
- Open your document; preferably it's a template you're using.
- Hit Alt+F11 to open the Visual Basic Editor (VBE).
- At left, double-click on ThisDocument.
- Paste the code into the code window at right.
- Change "LogID" to whatever you desire.
- Change "mm-dd-yy" to "dd-mm-yyyy" or any other format you choose.
- Close the VBE, save the file (important!).
|
Test the code:
|
- Close the file without using the Save or Save as options.
|
Sample File:
|
No Attachment
|
Approved by Anne Troy
|
This entry has been viewed 160 times.
|
|