![]() |
|
#1
|
|||
|
|||
![]() Hello, I currently use the macro below to give me the number of added words when looking at a document with track changes. I would also like to return the number of words in this sentence. How can I do that? Thank you! HTML Code:
Sub GetTCStats() Dim lInsertsWords As Long Dim lInsertsChar As Long Dim lDeletesWords As Long Dim lDeletesChar As Long Dim sTemp As String Dim oRevision As Revision lInsertsWords = 0 lInsertsChar = 0 lDeletesWords = 0 lDeletesChar = 0 For Each oRevision In ActiveDocument.Revisions Select Case oRevision.Type Case wdRevisionInsert lInsertsChar = lInsertsChar + Len(oRevision.Range.Text) lInsertsWords = lInsertsWords + oRevision.Range.Words.Count Case wdRevisionDelete lDeletesChar = lDeletesChar + Len(oRevision.Range.Text) lDeletesWords = lDeletesWords + oRevision.Range.Words.Count End Select Next oRevision sTemp = "Insertions" & vbCrLf sTemp = sTemp & " Words: " & lInsertsWords & vbCrLf sTemp = sTemp & " Characters: " & lInsertsChar & vbCrLf sTemp = sTemp & "Deletions" & vbCrLf sTemp = sTemp & " Words: " & lDeletesWords & vbCrLf sTemp = sTemp & " Characters: " & lDeletesChar & vbCrLf MsgBox sTemp End Sub |
#2
|
||||
|
||||
![]()
Return it where? If you mean add it to the end of the document, then add a boolean variable declaration DIM bRevision as Boolean and replace the message box with
Code:
bRevision = ActiveDocument.TrackRevisions ActiveDocument.TrackRevisions = False ActiveDocument.Range.InsertAfter vbCr & sTemp ActiveDocument.TrackRevisions = bRevision
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Andoheb | Word | 29 | 07-03-2014 01:48 PM |
![]() |
awolf | Word VBA | 7 | 03-16-2014 02:40 PM |
Append text to a sentence containing specific word | dgp | Word VBA | 3 | 02-28-2014 10:38 PM |
Modified Signature Line in Microsoft Word | gurp99 | Word | 0 | 03-28-2012 09:58 AM |
I want to lock a sentence in Word | smorkette | Word | 1 | 02-06-2010 12:57 AM |