Jay
Fri Sep 08 19:51:57 CDT 2006
That must mean that none of your "My Reference" paragraphs are located
together, but are all separated by paragraphs with other styles. If
you ever run the macro on a document that does have consecutive
reference paragraphs, you'll see a real infinite loop, not just a slow
one.
I suggest you take Klaus's advice before that happens.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ:
http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
On Fri, 8 Sep 2006 17:03:08 -0300, "ML" <schooner@accesswave.ca>
wrote:
>Turned out that this line was the issue:
>ActiveDocument.Range.Paragraphs.Count
>
>Seems calling this in the loop took an extremely long amount of time and
>perhaps has a memory leak. Called it once before the loop and set a
>variable and it worked fine.
>
>"ML" <schooner@accesswave.ca> wrote in message
>news:u4qpwV20GHA.1568@TK2MSFTNGP03.phx.gbl...
>> We currently have a macro to loop through a document and cound
>> "references" which are marked with a specifc style so that we can find
>> them. The issue is that this code seems to be hanging Word and not sure
>> why. Does anyone have any ideas on what the issue is or a better way to
>> handle this?
>>
>> With ActiveDocument.Range.Find
>> .Style = "My Reference"
>> While .Execute
>> l = l + 1
>> If l > ActiveDocument.Range.Paragraphs.Count Then
>> GoTo endloop
>> End If
>> Wend
>> End With
>> endloop:
>> ActiveDocument.CustomDocumentProperties("RefCount") = l
>>
>