F
Fool
I'm trying to do string processing on an index in a MS Word document.
The document itself is about 700 pages, and there are approximately
2500 lines in the index.
The code included here is just test code, but it demonstrates the
problem I am having. The code runs quickly until line 50 or so and
then gets slower and slower until it grinds to a halt an hour or two
later. It does not seem to matter what the initial value of 'n' is.
I'm wondering why the big slowdown performing a task that shoudn't eat
memory, and how it can be avoided. Any suggestions appreciated!
Sub testMe()
Dim r As Range
Dim n As Integer
Dim iEnd As Integer
iEnd = ActiveDocument.Indexes(1).Range.Paragraphs.Count
n = 1
While n < iEnd
Set r = ActiveDocument.Indexes(1).Range.Paragraphs(n).Range
Debug.Print "n is " & n
n = n + 1
Wend
End Sub
The document itself is about 700 pages, and there are approximately
2500 lines in the index.
The code included here is just test code, but it demonstrates the
problem I am having. The code runs quickly until line 50 or so and
then gets slower and slower until it grinds to a halt an hour or two
later. It does not seem to matter what the initial value of 'n' is.
I'm wondering why the big slowdown performing a task that shoudn't eat
memory, and how it can be avoided. Any suggestions appreciated!
Sub testMe()
Dim r As Range
Dim n As Integer
Dim iEnd As Integer
iEnd = ActiveDocument.Indexes(1).Range.Paragraphs.Count
n = 1
While n < iEnd
Set r = ActiveDocument.Indexes(1).Range.Paragraphs(n).Range
Debug.Print "n is " & n
n = n + 1
Wend
End Sub