![]() |
|
|
|
#1
|
||||
|
||||
|
Hi New Daddy,
It's nothing to do with Word 2003. Rather, it's that ComputeStatistics(wdStatisticWords) doesn't count text marked as deleted. Here's a workaround: Code:
Function CountRevisions(Rng As Range) As Long
Dim i As Long, j As Long, Str As String
With Rng
For i = 1 To .Revisions.Count
If .Revisions(i).Type = wdRevisionInsert Then
j = j + .Revisions(i).Range.ComputeStatistics(wdStatisticWords)
ElseIf .Revisions(i).Type = wdRevisionDelete Then
Str = Trim(.Revisions(i).Range.Text)
Str = Replace(Str, vbCr, " ")
While InStr(Str, " ") > 0
Str = Replace(Str, " ", " ")
Wend
j = j - (UBound(Split(Str, " ")) + 1)
End If
Next
End With
CountRevisions = j
End Function
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#2
|
|||
|
|||
|
Quote:
But recently, it started to cause an '5852 run-time error', where the following code kicks in. This is really strange, because it was fine a few days ago. Any idea why? If .Revisions(i).Type = wdRevisionInsert Then Last edited by macropod; 12-09-2012 at 05:32 PM. Reason: Deleted unnecessary quote of portions of post replied to |
|
#3
|
|||
|
|||
|
Quote:
It turns out that Word sometimes ignores apparently deleted text in running through revisions. I noticed it after the revision count macro seemingly did not subtract the deleted words. I modified the function so I can see each deleted revision that Word (or the macro here) goes through. Sure enough, Word skips some deleted revision. The behavior is really erratic. Sometimes the same deleted portion would be recognized by the macro, and other times not. I can't really figure out what's causing it. Any idea? Code:
Function CountNetRevisions(Rng As Range) As Long
Dim i As Long, j As Long, Str As String
With Rng
On Error Resume Next
For i = 1 To .Revisions.Count
If .Revisions(i).Type = wdRevisionInsert Then
j = j + .Revisions(i).Range.ComputeStatistics(wdStatisticWords)
ElseIf .Revisions(i).Type = wdRevisionDelete Then
MsgBox (.Revisions(i).Range.Text)
Str = Trim(.Revisions(i).Range.Text)
Str = Replace(Str, vbCr, " ")
While InStr(Str, " ") > 0
Str = Replace(Str, " ", " ")
Wend
j = j - (UBound(Split(Str, " ")) + 1)
End If
Next
End With
CountNetRevisions = j
End Function
|
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Counting Colors
|
g48dd | Excel | 2 | 03-13-2011 09:28 PM |
| Added letters to body message | kawzie | Outlook | 1 | 07-12-2010 11:00 AM |
Half hour added between tasks
|
maruchi | Project | 1 | 06-17-2010 08:06 AM |
| Form field to automatically be added to header? | razberri | Word VBA | 3 | 02-22-2010 03:48 PM |
Help! All Messages in Web Email deleted when account added to Outlook
|
UrbanEast | Outlook | 2 | 07-17-2009 09:32 PM |