Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2006

Tip: Looking for answers? Try searching our database.

TablesOfContents.Add Error?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brandon - 05 Aug 2005 17:15 GMT
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?
Cindy Meister - 08 Aug 2005 08:02 GMT
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
[quoted text clipped - 4 lines]
> Does this not work backwards? Is there a workaround? Am I overlooking
> something?
Brandon Jones - 11 Aug 2005 06:05 GMT
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
>
[quoted text clipped - 21 lines]
> > Does this not work backwards? Is there a workaround? Am I overlooking
> > something?
Cindy Meister - 11 Aug 2005 07:42 GMT
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

> 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
[quoted text clipped - 42 lines]
> > > Does this not work backwards? Is there a workaround? Am I overlooking
> > > something?
Brandon Jones - 11 Aug 2005 13:50 GMT
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.

> Hi Brandon
>
[quoted text clipped - 51 lines]
> > > > Does this not work backwards? Is there a workaround? Am I overlooking
> > > > something?
Cindy Meister - 11 Aug 2005 14:27 GMT
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

> > Hi Brandon
> >
[quoted text clipped - 65 lines]
> overlooking
> > > > > something?
Dave - 17 Mar 2006 06:46 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.