The code works fine in interpreted form, that is as a macro running inside
of Word regardless of the OS or Word version. In other words, I never had a
macro crash.
The problem is in the compiled version, in this case as a VB-compiled exe
file. Created and compiled and under Windows XP/Word 2003, it works fine on
Word 11 and 10 (2003 and XP respectively). It crashes consistently under
Word 9 (Word 2000). The interesting thing is this crash is not trapped by
the on error statements but goes directly to the OS.
To answer your questions: this happens on either a new or existing document,
the TOC through the menu works fine in any case, the test code has been
stripped down the bare bones (containing a single line
[ActiveDocument.TablesOfContents.Add Range:=Selection.Range]), using those
different templates does not change any result.
Cindy Meister said:
Hi Brandon
It should work; and I can't recall that there was any problem in Word 2000
with this.
Are you using this on existing document, new documents, or ...? If you try
to add a TOC using the menus in Word, does it also crash, or does that work?
If it works, and your record it in a macro, does the code differ
significantly from your code? if you substitute the macro recorder code for
your code, does it run any differently?
If Word is still crashing, try renaming Normal.dot to NormalOLD.dot, restart
Word, and test your macro on a NEW document.
-- Cindy