PatternNut
Programmer
- Jul 29, 2007
- 5
Hi,
I'm designing a Word add-in. The add-in has a modeless form that runs with the activedocument and helps authors to improve their writing.
As part of that, I have an array that provides information on every paragraph in the document. Everything works really well until the user has to make some changes in the document and starts deleting or adding paragraphs. When they do that, the array no longer corresponds to the correct paragraph.
I designed a system that re-aligns the paragraphs (based on variables such as number of words and first word). It re-aligns the paragraphs with more than 99% accuracy. That's accurate enough, but it's a bit too slow because it goes through the entire document like this (instantaneous in short documents but several seconds in very long ones):
For Each para in activedocument.paragraphs
lngParaNumber = lngParaNumber + 1
arrWordCount(lngParaNumber ) = para.range.words.count
Next para
Is there a better way to tell if the user has made changes? Is there a way to tell if the user activates the activedocument window instead of the form? Is there a way to tell if paragraphs are added or deleted? Is there a way to better link an array to each paragraph? Is there something else that I haven't thought of.
Thanks in advance for any ideas that you have.
Cheers,
PatternNut
I'm designing a Word add-in. The add-in has a modeless form that runs with the activedocument and helps authors to improve their writing.
As part of that, I have an array that provides information on every paragraph in the document. Everything works really well until the user has to make some changes in the document and starts deleting or adding paragraphs. When they do that, the array no longer corresponds to the correct paragraph.
I designed a system that re-aligns the paragraphs (based on variables such as number of words and first word). It re-aligns the paragraphs with more than 99% accuracy. That's accurate enough, but it's a bit too slow because it goes through the entire document like this (instantaneous in short documents but several seconds in very long ones):
For Each para in activedocument.paragraphs
lngParaNumber = lngParaNumber + 1
arrWordCount(lngParaNumber ) = para.range.words.count
Next para
Is there a better way to tell if the user has made changes? Is there a way to tell if the user activates the activedocument window instead of the form? Is there a way to tell if paragraphs are added or deleted? Is there a way to better link an array to each paragraph? Is there something else that I haven't thought of.
Thanks in advance for any ideas that you have.
Cheers,
PatternNut