J
John Wirt
I need a procedure that will print out all of the revisions in a document
along with their "parent" paragraph and sentence numbers. Here is the code
I've used (thx Helmut Weber for cmts):
For I = 1 To ActiveDocument.Paragraphs.Count
Set rngPara = ActiveDocument.Paragraphs(I).Range
For J = 1 To rngPara.Sentences.Count
Set rngSent = rngPara.Sentences(J)
Debug.Print "Paragraph " & Format(I, "00") & " Sentence " &
Format(J, "00") & " #Deletions= "; Str(cntDeletions) & " #Insertions= " &
Str(cntInsertions)
If rngSent.Revisions.Count > 0 Then
cntDeletions = 0
cntInsertions = 0
For Each Revn In rngSent.Revisions
If Revn.Type = wdRevisionDelete Then
cntDeletions = cntDeletions + 1
strRevnType = "Deletion:"
ElseIf Revn.Type = wdRevisionInsert Then
cntInsertions = cntInsertions + 1
strRevnType = "Insertion:"
End If
Debug.Print strRevnType; Revn.Range.Text
Next Revn
End If
Next J
Next I
The problem is that the revisions in the range rngSent.Revisions includes
_all_ of the revisions in the document rather than just the revisions in
pargraph, I, and sentence, J, as the code specifies should be the case.
Prior to iterating to the first paragraph _and_ sentence containing a
revision, the count of revisions rngSent.Revisions is 0, which is correct.
At the first _sentence_ containing a revisions, the count of revisions (and
the print out of revisions) jumps to all revisions in the document.
What is wrong here?
I am using the 9/2/2003 Word Patch, which contains repairs to Revisions (see
kb824936 thx ejlskov)
John Wirt
along with their "parent" paragraph and sentence numbers. Here is the code
I've used (thx Helmut Weber for cmts):
For I = 1 To ActiveDocument.Paragraphs.Count
Set rngPara = ActiveDocument.Paragraphs(I).Range
For J = 1 To rngPara.Sentences.Count
Set rngSent = rngPara.Sentences(J)
Debug.Print "Paragraph " & Format(I, "00") & " Sentence " &
Format(J, "00") & " #Deletions= "; Str(cntDeletions) & " #Insertions= " &
Str(cntInsertions)
If rngSent.Revisions.Count > 0 Then
cntDeletions = 0
cntInsertions = 0
For Each Revn In rngSent.Revisions
If Revn.Type = wdRevisionDelete Then
cntDeletions = cntDeletions + 1
strRevnType = "Deletion:"
ElseIf Revn.Type = wdRevisionInsert Then
cntInsertions = cntInsertions + 1
strRevnType = "Insertion:"
End If
Debug.Print strRevnType; Revn.Range.Text
Next Revn
End If
Next J
Next I
The problem is that the revisions in the range rngSent.Revisions includes
_all_ of the revisions in the document rather than just the revisions in
pargraph, I, and sentence, J, as the code specifies should be the case.
Prior to iterating to the first paragraph _and_ sentence containing a
revision, the count of revisions rngSent.Revisions is 0, which is correct.
At the first _sentence_ containing a revisions, the count of revisions (and
the print out of revisions) jumps to all revisions in the document.
What is wrong here?
I am using the 9/2/2003 Word Patch, which contains repairs to Revisions (see
kb824936 thx ejlskov)
John Wirt