TablesOfContents.Add Error?

B

Brandon

The following code:
ActiveDocument.TablesOfContents.Add Range:=Selection.Range
works OK in the Word 2003 and Windows XP it was created in. But in Windows
2000/Word 2000 it crashes the application and doesn't even get trapped by the
onerror statement.

Does this not work backwards? Is there a workaround? Am I overlooking
something?
 
C

Cindy Meister

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
 
C

Cindy Meister

Hi Brandon

With which Word library did you compile your *.exe? If you didn't develop,
test and compile with the olb for Word 2000 (9.0), then problems can occur.
The TYPE LIBRARIES are *not* backwards compatible. (They should be forwards
compatible, but they aren't always.)

-- Cindy

Brandon Jones said:
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
 
B

Brandon Jones

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.
 
C

Cindy Meister

Hi Brandon
No, I used Word 2003's (version 11.0). Well, apparently I found a case that
it's not forward compatible.
No, that's backward compatibility you're talking about: the newer versions'
*.olb won't be accepted by earlier versions.
How do you solve this? Can 9.0 and 11.0 be loaded on the same machine? Do I
have to have two exe's, each checking Word versions before running some
code?
That's what Microsoft recommends, just because there are so many different
permuttaions that could cause problems. Especially switching between 2000 and
other version, BTW. 2000 has some weird stuff going on, internally. I did a
project - with a VBA template - where I ended up having to go through all
kinds of hoops (graphics stuff) with things that *ought* to have been the
same across all three versions. And finally ended up with separate template
for the 2000 version.

To answer your question, yes, you can install more than one version on a
machine, then reference the 9.0 version *olb in your project. But I don't
recommend it if you have an alternative. I discovered VMWare a few years ago,
and have never looked back. Or, there's virtual PC which does the same thing:
allows you to set up separate instances of Windows on the same machine,
without needing boot partitions or separate drives or some such.
Also, thank you very much for verifying this.
Well, it's still not certain we've found the problem. But at least it's a
starting point :)

-- Cindy
Cindy Meister said:
Hi Brandon

With which Word library did you compile your *.exe? If you didn't develop,
test and compile with the olb for Word 2000 (9.0), then problems can occur.
The TYPE LIBRARIES are *not* backwards compatible. (They should be forwards
compatible, but they aren't always.)

-- Cindy

Brandon Jones said:
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.

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

:

The following code:
ActiveDocument.TablesOfContents.Add Range:=Selection.Range
works OK in the Word 2003 and Windows XP it was created in. But in
Windows
2000/Word 2000 it crashes the application and doesn't even get trapped
by the
onerror statement.

Does this not work backwards? Is there a workaround? Am I overlooking
something?
 
B

Brandon Jones

No, I used Word 2003's (version 11.0). Well, apparently I found a case that
it's not forward compatible.

How do you solve this? Can 9.0 and 11.0 be loaded on the same machine? Do I
have to have two exe's, each checking Word versions before running some
code?

Also, thank you very much for verifying this.

Cindy Meister said:
Hi Brandon

With which Word library did you compile your *.exe? If you didn't develop,
test and compile with the olb for Word 2000 (9.0), then problems can occur.
The TYPE LIBRARIES are *not* backwards compatible. (They should be forwards
compatible, but they aren't always.)

-- Cindy

Brandon Jones said:
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

:

The following code:
ActiveDocument.TablesOfContents.Add Range:=Selection.Range
works OK in the Word 2003 and Windows XP it was created in. But in Windows
2000/Word 2000 it crashes the application and doesn't even get
trapped
by the
onerror statement.

Does this not work backwards? Is there a workaround? Am I overlooking
something?
 
D

Dave

I have the same problem with a VB 6 program written in Windows 98 and Word 8.
If I compile the program on Windows 98, it runs with all versions of Word.
As soon as I compile it (in VB6) on a machine that has Word 9 (2000) it
crashes the Word program.

Something that I found that is interesting, but doesn't help to solve it is,
If I look in the task manager, the process WINWORD.EXE still keeps running,
even after the task dies and gives me the message about sending the dump to
Microsoft...

In my case, I also get no error messages or indication that anything is
wrong. The program just hangs...
I tried generating the code in a macro recording and pasting the exact code
into my program and it still craches when run from my program, while running
fine from within Word.
 

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