Outof Memory Error When Programatically Resetting Numbering

P

Peter Hewett

Hi All

Word 2000/Windows 2000.

I have a Wizard that merges documents together, nothing particularly
fanciful. The documents being merged are almost completely built around
outline numbering. The outline numbering is a simple 4 level affair that
works well.

The outline numbering is built using the standard technique:
1. Create a named ListTemplate
2. Define the styles
3. Define the ListLevels
4. Set the ListLevels linked style

There are quite a few of these documents (100+) so for absolute consistency
all the above is done in code. All documents use the same template (which
is not the Wizard of course).

The template and all documents have had their list numbering setup using
this code.

As each document is merged I restart list numbering for the level 1 outline
style. This is to prevent follow on numbering from the previous document.
List numbering is reset using the standard method of:

With .ListFormat
.ApplyListTemplate .ListTemplate, False
End With

And this is where the problem starts, I'm getting an "Out of memory" error
when executing the above statement! This is some 60+ documents into the
merge. At the time it fails the document's some 66 Sections, 650+ pages
long and the ListTemplate count is 1,790 and the ListParagraph count is
7,693.

I've tried most of the obvious stuff: Flush the documents undo buffer, save
document, etc. Within the VBA IDE I've skipped over this statement and
forced execution to continue - which it does until the next time it hits
the same statement. So the problem is not memory in general (because it can
do other memory hungry things) but memory as it applies to ListTemplates.

I know about the hidden paragraph trick as an alternate way to reset
numbering and I know about ListNum fields, but I don't want to have to
revise all of these documents if at all possible.

Obviously reducing the number of ListTemplates in each document is a
prerequisite, but is there any reliable way to do this?

Your thoughts, ideas and suggestions (other than what I can do with it!)
are warmly welcomed!

Almost anything constructive considered!

Thanks in advance + Cheers - Peter
 
W

Word Heretic

G'day Peter Hewett <[email protected]>,

Try an ActiveDocument.UndoClear just before the edit in your main
loop.

Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


Peter Hewett reckoned:
 
W

Word Heretic

G'day Peter Hewett <[email protected]>,

Hokay. Dont ref the LT's by name, search through the collection for
the name that matches and use that offset

eg:

BAD

ListTemplates("My big un").

GOOD

ListTemplates(2)


Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


Peter Hewett reckoned:
 
P

Peter Hewett

Hi Steve

I don't actually refer to the ListTemplates by Name or by Index. I'm usin'
the Find method that contains a first level outline created in the first
place from a named ListTemplate. Code abstract:

If Selection.Find.Execute Then

' Reset the outline numbering of the first "Heading 1"
' style in the file we just inserted. Otherwise numbering
' will continuing from the previously inserted document.
With Selection.Range
.Collapse wdCollapseStart

' Reapply the current ListTemplate
With .ListFormat
.ApplyListTemplate .ListTemplate, False
End With
End With
End If

I've written some code to create new a document based on the common template.
The old document is then copied (excluding the last bookmark) to the new
document and paragraph styles reapplied.

The Wizard is working fine using the new files. A 72 file, 710 page output
document now only contains 51 ListTemplates!!

Man, Words seriously screwed.

I've just done a very quick test using Word XP and the code (as above):

With .ListFormat
.ApplyListTemplate .ListTemplate, False
End With

fails because using Word XP the ListTemplate (.ListTemplate) is Nothing!!!

Cheers - Peter
 
W

Word Heretic

G'day Peter Hewett <[email protected]>,

try going via the .listparagraphs


Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


Peter Hewett reckoned:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top