TOC in Word 2007

R

Roderick O'Regan

Word 2007 in Vista Business.

I've got a template (.dotm) with two TOCs. The first one is three
levels deep (Headings 1 to 3) and the second one showing two levels
deep and used for Appendices (Using Headings 7 & 8). These TOCs are
created programmatically.

I've created a button on a custom tab to update fields and TOCs.

The line of code to update the TOCs says:
with ActiveDocument
..TablesOfContents(1).Update
..TablesOfContents(2).Update
End With

When I run the procedure to update the TOCs I get an error which says
something to the effect:
"Method Update of Object TableOfContents failed".

Nothing gets updated!

Now here is the strange bit: using this coding in a Word 2003 template
works perfectly. Bring it over to W2007 and it doesn't work.

Is there something new about TOCs in W2007 and VBA coding that I've
missed? Could someone advise, please?

Roderick
 
S

Suzanne S. Barnhill

Does your macro take into account the fact that pressing F9 in a TOC will
ordinary pop up a dialog requiring a choice between the entire table and
just the page numbers? That would be true in any version, however.
 
R

Roderick O'Regan

Thanks for the reply Suzanne.

Actually, pressing F9 within a TOC in my .dotm template does nothing
at all.

The thing that is really disturbing is that the exact coding and
structure in W2003 works perfectly. Put it into W2007 and errors
mentioned previously appear.

The only way I can get all my TOCs and TOFs to update is to go to (in
W2007) References>Update Table.

Using the macro recorder to see what it is actually doing, it uses, of
all things the coding 'Wordbasic.UpdateTableOfContents' of all things!

Roderick
 
S

Suzanne S. Barnhill

Oh, ouch! Another example of how impossible it is to completely eradicate
Word Basic from VBA!
 

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