PDA

View Full Version : Notifying Users that Document has Tracked Changes on Save or Open



bstephens
12-29-2010, 02:24 PM
Greetings,

First, I wanted to thank everyone for all the amazing feedback I have received in this forum this year! Thank You! I have almost finalized a word add-in for the legal community, when it is ready, I am going to release it as freeware under an open license.

New question, does anyone have a macro that will intuitively inform the user that the document contains tracked changes?

I was thinking of a macro that does the following:

Automatically on an "open"or "save" event in word:
If the track changes view is set to "final" or "original" (so that markup is not being shown, in other words the track changes are invisible)
and if thedocument actually contains tracked changes, then --> an informational box will pop up informing the user that the document contains "n" tracked changes on a save or open event (where "n" is the number of tracked changes)
If the track changes view is set to "final: show markup" or "original: show markup" (so that track changes are visible) --> then nothing happens because it already...hopefully...obvious there are changes (they are...generally...visible in the document).
If there are no track changes --> nothing happensI welcome any ideas to improve the logic of this proposed macro or any code which accomplishes a similar idea.

Regards,
Brian

fumei
12-29-2010, 03:48 PM
"New question, does anyone have a macro that will intuitively inform the user that the document contains tracked changes?"

Ummmm, I do not know how intuitive it is, but if the document has tracked changes (and they have not been accepted), then they are visible as soon as TC is turned on, including any that were previous invisible.


You logic is OK, although there is a difference between "open" and "save".

Having actions occur during "Open" does not require application events (using a Class module). During Save does.

Regarding N changes (i.e. a count), be aware that if you have track changes on, .Count can give wonky returns:
If ActiveDocument.Range.Revisions.Count <> 0 Then
MsgBox "equals 0 " & ActiveDocument.Range.Revisions.Count
Else
MsgBox "NOT zero " & ActiveDocument.Range.Revisions.Count
End If
Suppose you make a new document. Do nothing. Set track changes on. DO NOTHING. Execute. You get:

"NOT zero " 0 (even though it IS 0)

Now change it to: If ActiveDocument.Range.Revisions.Count = 0 Then
MsgBox "equals 0 " & ActiveDocument.Range.Revisions.Count
Else
MsgBox "NOT zero " & ActiveDocument.Range.Revisions.Count
End If
DO NOTHING. Execute. Now you get.

"equals 0 " 0

.Count does in fact = 0.

Also, note that programmatically, .RevisionsView only has two values:

wdRevisionsViewOriginal
wdRevisionsViewFinal

What makes the four (Final, Final with Markup, Original, Original with Markup) is the combination of .RevisionsView and .ShowRevisionsAndComments. Sooooo....
If ActiveWindow.View.ShowRevisionsAndComments = False AND _
ActiveWindow.View.RevisionsView = wdRevisionsViewOriginal Then
means Original.


If ActiveWindow.View.ShowRevisionsAndComments = True AND _
ActiveWindow.View.RevisionsView = wdRevisionsViewOriginal Then
means Original with Markup.

But as an example for a Doc_Open:

Private Sub Document_Open()
If ActiveDocument.Range.Revisions.Count = 0 Then
' do nothing
Else
MsgBox "This document has " & ActiveDocument.Range.Revisions.Count & _
" tracked changes."
End If
End Sub

bstephens
12-29-2010, 05:09 PM
Gerry, thank you so much for this information. I am going to code something tonight, and will post it for review and the benefit of the community once completed.

macropod
12-29-2010, 10:01 PM
Hi gerry,

if the document has tracked changes (and they have not been accepted), then they are visible as soon as TC is turned on, including any that were previous invisible.not so fast m'lad!

You can have tracked changes 'on' but not shown. For Brian's requirement, I think a simple test along the lines of:
With ActiveDocument
If .TrackRevisions = True Then _
If .ShowRevisions = False Then _
If .Revisions.Count > 0 Then _
MsgBox .Revisions.Count & " outstanding Tracked Change(s) is/are in this document."
End Withwill fit the specifications. This code is compatible all the way back to Word 2000 (at least) whereas:

ActiveWindow.View.ShowRevisionsAndComments
and the like require Word 2003 and later.

fumei
12-31-2010, 10:40 AM
Doh.