Tuesday, December 16, 2008

How to set and reset track changes using Word VBA

Word VBA Set / Reset TrackRevisons
When you create a macro to do some operations that are not concerned with the content of the document, it is always advisable to do it without track changes. It is also better to turn-off the changes on screen as the deleted text might interfere with the process.
When you turn off the TrackRevisons and ShowRevisions, it is always best to leave them in their old state after the operation.
The following code does exactly the same
Sub SetAndReset_TrackRevisions()
Dim bTrackRevFlag As Boolean
Dim bShowRevFlag As Boolean
bTrackRevFlag = ActiveDocument.TrackRevisions
 bShowRevFlag = ActiveDocument.ShowRevisions
ActiveDocument.TrackRevisions = False
ActiveDocument.ShowRevisions = False
' Do Some Operations
Call TagDocument
ActiveDocument.TrackRevisions = bTrackRevFlag
ActiveDocument.ShowRevisions = bShowRevFlag
End Sub
The VBA code for autotagging the document switches off the tracking and resets them to their original position after the TagDocument subroutine is executed


  1. You never store a value to bShowRevFlag e.g. bShowRevFlag = ActiveDocument.ShowRevisions

  2. And 7 years later the mistake is still there.


Share on Facebook
Related Posts Plugin for WordPress, Blogger...
Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.