Quantcast
Viewing all articles
Browse latest Browse all 15778

MsOf13 [Word] Excluding punctuation from tracked changes counts

Hi all,

I have been working with the below macro for some time. The macro calculates 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


Viewing all articles
Browse latest Browse all 15778

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>