JonasKullenwall
Mon Sep 11 09:14:01 CDT 2006
With simple document I ment no tables, images, drawing objects, objects , or
other "special" effects applied to the text. However, I would agree on that
the document is quite large.
I tried your suggestions with no significant result on the performance.
However, when I used the same macro in Word 2000 (XP SP2) I get the same slow
execution time at the first run but the second run was executed under 1 s.
If I was able to achieve the same behavior on Word 2003, that should be
acceptable.
Do you think that it is possible, by tweaking some other settings?
Jonas
"Cindy M." wrote:
> Hi =?Utf-8?B?Sm9uYXMgS3VsbGVud2FsbA==?=,
>
> It sounds to me like the TOC may first be updating (although I'd find that
> strange) or the document is repaginating. You may consider a TOC with 300
> entries and 123 pages with lots of headings "simple", but calculating the TOC
> definitely is not; and depending on the style definitions, calculating the
> layout could be very resource-intensive.
>
> You might see what happens if you select the TOC (field) then press Ctrl+F11 to
> lock it (so it can't update - Ctrl+Shift+F11 would unlock, and there are object
> model equivalents if you need it in your code).
>
> The next thing I'd try is to go into Normal view, then in Tools/Options/General
> deactivate Background Pagination (this is only possible in Normal view). See if
> this makes any difference when you run your code.
>
> > I have written a macro to extract data from the active document. The macro
> > should be a part of an algorithm to auto detect headings. The problem is that
> > I get very long delays when accessing the DOM.
> >
> > A code-snippet that show this behavior:
> >
> > Dim nCount as Long
> > Dim oSents as Sentences
> > Dim sText as String
> >
> > Set oSents = ActiveDocument.Sentences
> > if not oSent is nothing then
> > nCount = oSents.Count
> > if nCount > 1 then
> > sText = oSent.Item(nCount - 1).Text
> > endif
> > endif
> >
> > For certain documents the Sentences::Count will take approx. 10s to execute.
> > Range::Text takes also approx 10 s to execute. The document is quite simple
> > with a TOC (~300 items), body text and a lot of heading. The document has 123
> > pages. I a would try to iterate through all sentences in this document it
> > would have taken to long time to be acceptable.
> >
> > However, if I remove the table of content, then the execution time will be
> > below 1 s. Could someone explain why and is there any settings in Word that I
> > could modify to get rid of this problem? I have tried to run Word in safe
> > mode and also protected the document for editing with no performance
> > differences.
> >
> > I am running Word 2003 and Win XP SP 2. My computer does not lack in
> > performance.
> >
>
> Cindy Meister
> INTER-Solutions, Switzerland
>
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
>
http://www.word.mvps.org
>
> This reply is posted in the Newsgroup; please post any follow question or reply
> in the newsgroup and not by e-mail :-)
>
>