Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-23-2021, 07:40 AM
jimmy12 jimmy12 is offline Excluding punctuation from tracked changes counts Windows 10 Excluding punctuation from tracked changes counts Office 2016
Novice
Excluding punctuation from tracked changes counts
 
Join Date: May 2021
Posts: 4
jimmy12 is on a distinguished road
Question Excluding punctuation from tracked changes counts

Hi all,

I have been working with the below macro for some time so that I can see the number of words inserted and deleted when using tracked changes. However, I've noticed that the count statistics are slightly different compared to the standard counts provided by Word automatically. I think the issue is that the macro below is slightly over-sensitive and counts each new item of punctuation as a separate word. I'm not sure how best to edit the macro to exclude items of punctuation from the counts. Any tips would be appreciated.

Code:
Sub GetTCStats()
'
' GetTCStats Macro

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

Reply With Quote
Reply

Tags
tracked changes, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Excluding punctuation from tracked changes counts VBA code help: replacing punctuation Shelley Lou Word VBA 8 07-01-2021 04:42 AM
Excluding punctuation from tracked changes counts How to delete all the punctuation marks from a paragraph? Jamal NUMAN Word 3 02-26-2019 02:33 PM
Excluding punctuation from tracked changes counts punctuation order fariz Word 2 10-31-2016 12:57 AM
Replacing punctuation marks with footnotes nufc89 Word 2 05-22-2015 03:15 PM
Punctuation lexsper Word 0 04-06-2015 07:26 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:32 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft