Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Closed Thread
 
Thread Tools Display Modes
  #16  
Old 12-09-2012, 11:05 PM
New Daddy New Daddy is offline Word counting macro for newly added portion? Windows Vista Word counting macro for newly added portion? Office 2003
Advanced Beginner
Word counting macro for newly added portion?
 
Join Date: Jan 2012
Posts: 90
New Daddy is on a distinguished road
Default


Quote:
Originally Posted by macropod View Post
I'm not aware of anything in the code that could account for that. Perhaps re-starting Word (or even Windows) will resolve the problem. If not, try repairing the Office installation (via Help|Detect & Repair for Word 2003 & via Programs & Features > Microsoft Office > Change in the Windows Control Panel for Word 2010).

PS: There's no need to quote each previous post in its entirety every time you make a reply. Quote only when you need to and only those parts warranting it.
Re-starting Word or the OS didn't help.

In order to search what in the document was causing this issue, I went through every revision in the document from the beginning, using Word's FindNextRevision button. Surprisingly, a revision in a table was causing an endless loop. Pressing the FindNextRevision button repeatedly still resulted in circling around the revised word in the table. I have no idea what caused this particular revision to behave this way, but I think that part was wreaking havoc with the macro. When I accepted the revision in the table, I no longer experienced the run-time error.
  #17  
Old 12-11-2012, 08:35 PM
macropod's Avatar
macropod macropod is offline Word counting macro for newly added portion? Windows 7 64bit Word counting macro for newly added portion? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your mention of revisions within a table reminded me of: http://support.microsoft.com/kb/913804. According to http://support.microsoft.com/kb/841539, this was fixed in Office 2003 Service Pack 2, which raises thequestion: Do you have Office 2003 Service Pack 2 or later installed?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
  #18  
Old 12-12-2012, 08:51 AM
New Daddy New Daddy is offline Word counting macro for newly added portion? Windows Vista Word counting macro for newly added portion? Office 2003
Advanced Beginner
Word counting macro for newly added portion?
 
Join Date: Jan 2012
Posts: 90
New Daddy is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Your mention of revisions within a table reminded me of: http://support.microsoft.com/kb/913804. According to http://support.microsoft.com/kb/841539, this was fixed in Office 2003 Service Pack 2, which raises thequestion: Do you have Office 2003 Service Pack 2 or later installed?
Your wealth of knowledge is astounding.

I checked my Word version in the Help menu, and I have Service Pack 3 even. Not a firm believer in the robustness of Microsoft's operation, I refused to give MS the benefit of the doubt and personally went to see the registry under HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\W ord\Options.

Surprise! (Well, actually I wasn't surprised.) There was still no AlternateRevisionStepThrough key in there. I have no idea what transpired when Service Pack 3 was installed, but the key must have been removed some time ago if Service Pack 2 had ever installed it.

Anyways, I've manually inserted the key, as instructed by the Knowledge Base, and the problem is gone!

Thanks so much!
  #19  
Old 12-19-2012, 08:16 AM
New Daddy New Daddy is offline Word counting macro for newly added portion? Windows Vista Word counting macro for newly added portion? Office 2003
Advanced Beginner
Word counting macro for newly added portion?
 
Join Date: Jan 2012
Posts: 90
New Daddy is on a distinguished road
Default

And the long saga continues.

Would a picture (inserted as a file through Insert-Picture command) cause an error with this macro? I inserted a JPG file in the document and started facing run-time error 5917.
  #20  
Old 12-19-2012, 06:13 PM
macropod's Avatar
macropod macropod is offline Word counting macro for newly added portion? Windows 7 64bit Word counting macro for newly added portion? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by New Daddy View Post
Would a picture (inserted as a file through Insert-Picture command) cause an error with this macro? I inserted a JPG file in the document and started facing run-time error 5917.
Possibly. Try inserting:
On Error Resume Next
before:
For i = 1 To .Revisions.Count
That should allow the macro to skip over such errors.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
  #21  
Old 09-18-2013, 06:30 AM
New Daddy New Daddy is offline Word counting macro for newly added portion? Windows Vista Word counting macro for newly added portion? Office 2003
Advanced Beginner
Word counting macro for newly added portion?
 
Join Date: Jan 2012
Posts: 90
New Daddy is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
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
In continuation of this wonderful saga:

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
  #22  
Old 09-28-2013, 04:24 AM
macropod's Avatar
macropod macropod is offline Word counting macro for newly added portion? Windows 7 32bit Word counting macro for newly added portion? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I've been OS for 3½ months, hence the delay in replying. Are you sure it's a deletion that's being missed, and not a move?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
  #23  
Old 09-30-2013, 07:14 AM
New Daddy New Daddy is offline Word counting macro for newly added portion? Windows Vista Word counting macro for newly added portion? Office 2003
Advanced Beginner
Word counting macro for newly added portion?
 
Join Date: Jan 2012
Posts: 90
New Daddy is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
I've been OS for 3½ months, hence the delay in replying. Are you sure it's a deletion that's being missed, and not a move?
Yes, I think you can easily reproduce the symptom by starting a new document, typing a few sentences and playing around with them.
  #24  
Old 09-30-2013, 02:11 PM
macropod's Avatar
macropod macropod is offline Word counting macro for newly added portion? Windows 7 32bit Word counting macro for newly added portion? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I've done that and haven't found any anomalies. Perhaps you could post a document that demonstrates the problem and describe how you went about creating the scenario.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
  #25  
Old 09-30-2013, 07:30 PM
New Daddy New Daddy is offline Word counting macro for newly added portion? Windows Vista Word counting macro for newly added portion? Office 2003
Advanced Beginner
Word counting macro for newly added portion?
 
Join Date: Jan 2012
Posts: 90
New Daddy is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
I've done that and haven't found any anomalies. Perhaps you could post a document that demonstrates the problem and describe how you went about creating the scenario.
Posting a document that can demonstrate this problem is tricky. I think it's situation-dependent rather than document-dependent. I can save a document but when I open it in a new session, the symptom goes away. I'll try to figure out when exactly this problem takes place.
Closed Thread



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word counting macro for newly added portion? 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
Word counting macro for newly added portion? 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
Word counting macro for newly added portion? Help! All Messages in Web Email deleted when account added to Outlook UrbanEast Outlook 2 07-17-2009 09:32 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:53 AM.


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