Help needed for Micrsoft Word Macro

S

Shyla

Hi,

I am trying to get the word count for the inserted text using Track
changes as "ON" in the word document.

The text on the document i have added is "Hello world".
When i am trying to get the count on macro then it is showing 1, but i
have inserted two words.

Please help me if you know how to get the count for the inserted text.

My code is like this
**********************************
Dim mySection As Section
Dim iCount As Integer

For Each mySection In ActiveDocument.Sections
iCount = iCount + mySection.Range.Revisions.Count
Next
MsgBox "Count is " & iCount
**********************************

Thanks
Shyla
 
M

macropod

Hi Shyla

I'm not sure whether you just want the total number of revisions, the number
of words in each revision, or the number of words in all revisions. The
following code does all three, though you need to be aware that Word treats
punctuation marks as words in their own right:

Sub ListRevisionChanges()
Dim Rev As Revision
Dim RWrd As Integer
RWrd = 0
MsgBox "# Revisions: " & ActiveDocument.Revisions.Count
For Each Rev In ActiveDocument.Revisions
MsgBox "Revision Text: " & Rev.Range.Text & vbCrLf & _
"Revision Words: " & Rev.Range.Words.Count
RWrd = RWrd + Rev.Range.Words.Count
Next
MsgBox "# Revision Words: " & RWrd
End Sub

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top