A family of Microsoft word processing software products for creating web, email, and print documents.
The problem occurs because we compare 2 ranges, not only one.
Should be solvable, can you send me a sample file?
Andreas.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Is there a non-resource-draining way to find 'nested revisions' in a document -- that is, spots where one reviewer has made a tracked insertion and another reviewer has deleted it (also tracked). So far the only method I've come up with is this:
Dim ch As Range
For Each ch In ActiveDocument.Characters
If ch.Revisions.Count > 1 Then ch.HighlightColorIndex = wdBrightGreen
Next
....which works, but as you can imagine, it not quick, and turns up a lot of false positives (flags every table row with multiple revisions in a cell -- even if not overlapping -- as nested). Is there a better way? Trying to cycle through revisions collection itself throws an error (object not available).
A family of Microsoft word processing software products for creating web, email, and print documents.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
The problem occurs because we compare 2 ranges, not only one.
Should be solvable, can you send me a sample file?
Andreas.
Nice, and very fast. But I notice a new problem: both your macro and mine STOP flagging overlaps when they reach a table!
It doesn't even seem possible to skip tables altogether. Adding
If Not R.Range.Information(wdWithinTable)
after the Set statement changes nothing.
Any ideas?
Mark
Why not test the positions of the range of each revision?
Andreas.
Sub Test()
Dim R As Revision
Dim Pos() As Long
Dim i As Long, j As Long
With ActiveDocument
ReDim Pos(1 To .Revisions.Count, 1 To 2)
For i = 1 To .Revisions.Count
Set R = .Revisions(i)
Pos(i, 1) = R.Range.Start
Pos(i, 2) = R.Range.End
For j = 1 To i - 1
If (Pos(i, 1) >= Pos(j, 1) And Pos(i, 1) <= Pos(j, 2)) Or _
(Pos(i, 2) >= Pos(j, 1) And Pos(i, 2) <= Pos(j, 2)) Then
'Overlaps
If Pos(i, 1) < Pos(j, 1) Then
.Range(Pos(j, 1), Pos(i, 2)).HighlightColorIndex = wdBrightGreen
Else
.Range(Pos(i, 1), Pos(j, 2)).HighlightColorIndex = wdBrightGreen
End If
End If
Next
Next
End With
End Sub
The problem with the revisions collection is that it seems to like only nice neat small revisions. The code below works with simple revisions in the middle of text but chokes (5825 obj not avail) when it looks at more complex types:
Dim rv As Revision
For Each rv In ActiveDocument.Revisions
If rv.Range.Revisions.Count > 1 Then
rv.Range.Revisions(2).Range.HighlightColorIndex = wdBrightGreen
End If
Next
I don't see what your suggested code is trying to do. I don't need the macro to query me on each revision it sees. I want it to highlight where a tracked insertion and a tracked deletion overlap.
MT
And what is the problem with the Revisions collection?
Andreas.
Sub Test()
Dim R As Revision
With ActiveDocument
'.TrackRevisions = True
.ShowRevisions = True
For Each R In .Revisions
If MsgBox(R.Author & " " & R.Date & " => " & R.Range.Text, vbOKCancel) <> vbOK Then Exit Sub
Next
End With
End Sub