logo
search
VBA & Macro Problems

How to Track Same-Day Document Revisions Using Word Macros

Olivia MillerOlivia Miller Oct 21, 2026 868 views

Question details

The user wants to label a Word document as an initial release or a revision, but needs a way to accurately track revisions that occur on the exact same day the document was created.

How to Track Same-Day Document Revisions Using Macros in Word
Product
Word
Device & OS
not provided
Scenario
Using standard IF field codes to compare CREATEDATE and SAVEDATE fails to properly distinguish same-day saves because the calendar dates match, and time-based field comparisons are unreliable.
Observed behavior
Comparing only the date does not identify same-day revisions, and comparing hours and minutes via fields is inconsistent because the first save can occur at nearly the same time as creation, while SAVEDATE only updates after saving.
Before you start

Ensure your document is saved as a Macro-Enabled Document (.docm) or Macro-Enabled Template (.dotm) and that the Developer tab is visible in your ribbon to access the VBA editor.

Solution 1Recommended

Use a DocumentBeforeSave Macro and Custom Property

Since time comparisons via field codes are unreliable, using a macro event to update a custom property immediately upon saving provides a foolproof way to label same-day revisions.

The SAVEDATE field is updated in the document after it is saved, meaning the updated value is typically only visible the next time the document is opened. Furthermore, comparing times is unreliable as a user might save the document for the first time in the exact same minute it was created.

A more robust alternative is configuring a custom property (e.g., 'Release Status') and updating it dynamically via VBA using the DocumentBeforeSave event handler.

1
Create a Custom Document Property

Go to File > Info > Advanced Properties. In the Custom tab, create a new text property named 'Release Status' and set its initial value to 'Initial Release:'.

2
Insert Fields into Your Document

In your document, insert a DOCPROPERTY field that references 'Release Status', followed immediately by a SAVEDATE field to timestamp the release or revision.

3
Open the VBA Editor

Press ALT + F11 to open the Visual Basic for Applications (VBA) editor. In the Project Explorer pane on the left, locate 'ThisDocument' under your specific document or template project.

4
Write the DocumentBeforeSave Code

Add an Application-level event handler for 'DocumentBeforeSave'. Write logic to check if 'ActiveDocument.Saved' is False. If it is False, and the 'Release Status' property currently reads 'Initial Release:', program the macro to change the property value to 'Revised:'.

5
Force Field Updates

Before concluding the save event inside your macro code, include a command to select the entire document and update all fields, ensuring the new property value displays immediately.

Use a DocumentBeforeSave Macro and Custom Property
Handling SAVEDATE Fields: Keep in mind that while your custom property updates instantly, the SAVEDATE field natively represents the time of the previous save operation. The newly updated SAVEDATE value will become fully apparent the next time the document is opened.

Create and Run Macros Seamlessly in WPS Writer

WPS Office provides robust support for VBA and macros, allowing you to easily implement custom document automation like DocumentBeforeSave events to track document revisions perfectly.

  1. 1. Open WPS Writer: Launch WPS Office and open your text document.
  2. 2. Access Developer Tools: Navigate to the Developer tab on the top ribbon.
  3. 3. Open the VBA Editor: Click on 'Macros' or the 'Visual Basic' icon to launch the coding environment and insert your DocumentBeforeSave script.
  4. 4. Save as Macro-Enabled: Go to Menu > Save As, and choose the Macro-Enabled Document format to preserve your newly added revision tracking script.
Full compatibility with Microsoft Word macro-enabled formats (.docm, .dotm)Built-in Visual Basic editor for writing, editing, and debugging custom scriptsLightweight architecture ensuring complex automated workflows run smoothlyFamiliar user interface for managing advanced custom document properties
microsoft office alternative - wps office

Frequently Asked Questions

Why does the SAVEDATE field not update immediately after I click save?

The SAVEDATE field records the time the document was last successfully saved. Because the field itself is part of the document content, updating its visual representation requires the save process to finalize first. You will typically see the new value upon reopening the file or manually forcing a field update.

Can I use an IF field to compare hours and minutes to detect revisions?

While technically possible using specific date-time picture switches, it is highly unreliable. The first manual save might happen in the same exact minute as the creation time, making the IF field fail to recognize it as a subsequent revision.

What is a custom document property in a text document?

A custom document property is a user-defined metadata field you create to store specific text, dates, or numbers relevant to your file. You can insert and display its value dynamically directly within your document content using a DOCPROPERTY field code.