C
Carlos Chalhoub
Hi listmates,
I created a macro that counts the number of revised words in a document. The
problem is that I don't want the macro to count the deleted text, just the
new text. What is happening is that when I hide the deleted text
(Options.DeletedTextMark = wdDeletedTextMarkHidden), Word is bombing and I
have to shut it down through task manager. When I omit the
"Options.DeletedTextMark = wdDeletedTextMarkHidden" line, the macro works,
but the deleted text is counted, which is not what I want.
I'm at my wits end. Can somebody show me what I'm doing wrong?
Thanks
Carlos
----------- Start of macro -----------------
Sub UnitFileCompare()
Dim oRev As Revision
Dim sallrev
Dim sAllRevWdCount
Dim numWords
'set revision mark options here
Options.DeletedTextMark = wdDeletedTextMarkHidden
Selection.WholeStory
Selection.Range.HighlightColorIndex = wdNoHighlight
If ActiveDocument.Revisions.Count <> 0 Then
'make a revisions collection here
For Each oRev In ActiveDocument.Revisions
sallrev = sallrev & oRev.Range.Text & vbCrLf
Next oRev
Else
MsgBox "There are no revisions in this document."
Exit Sub
End If
'count the number of words in the revisions collection here
Documents.Add
ActiveDocument.Range.InsertAfter sallrev
Set sAllRevWdCount = Dialogs(wdDialogToolsWordCount)
sAllRevWdCount.Execute
numWords = sAllRevWdCount.Words
MsgBox "Number of revised words:" & numWords
End Sub
----------- End of macro -----------------
I created a macro that counts the number of revised words in a document. The
problem is that I don't want the macro to count the deleted text, just the
new text. What is happening is that when I hide the deleted text
(Options.DeletedTextMark = wdDeletedTextMarkHidden), Word is bombing and I
have to shut it down through task manager. When I omit the
"Options.DeletedTextMark = wdDeletedTextMarkHidden" line, the macro works,
but the deleted text is counted, which is not what I want.
I'm at my wits end. Can somebody show me what I'm doing wrong?
Thanks
Carlos
----------- Start of macro -----------------
Sub UnitFileCompare()
Dim oRev As Revision
Dim sallrev
Dim sAllRevWdCount
Dim numWords
'set revision mark options here
Options.DeletedTextMark = wdDeletedTextMarkHidden
Selection.WholeStory
Selection.Range.HighlightColorIndex = wdNoHighlight
If ActiveDocument.Revisions.Count <> 0 Then
'make a revisions collection here
For Each oRev In ActiveDocument.Revisions
sallrev = sallrev & oRev.Range.Text & vbCrLf
Next oRev
Else
MsgBox "There are no revisions in this document."
Exit Sub
End If
'count the number of words in the revisions collection here
Documents.Add
ActiveDocument.Range.InsertAfter sallrev
Set sAllRevWdCount = Dialogs(wdDialogToolsWordCount)
sAllRevWdCount.Execute
numWords = sAllRevWdCount.Words
MsgBox "Number of revised words:" & numWords
End Sub
----------- End of macro -----------------