Inserting Tables of Contents, Tables and Figures

S

Samurai

I have Document Template that contains a Table of
Contents. I have a couple of Macros that insert Tables of
Tables and Tables of Figures. The Macros look for 2
bookmarks. One bookmark is stored at the end of the Table
of Contents field, so that the Table of Tables always
ends up in the right place and can't be deleted by
mistake. The problem is the 2nd bookmark keeps getting
deleted if I delete the Table of Figures and the Table of
Tables.

Also, if I were to delete the Table of Contents, then the
Table of Table bookmark would disappear.

What I need to do is be able to insert the Table of
Contents in a certain place, if it gets deleted and then
insert the other 2 tables after it. For example, if the
Table of Tables is there, then the Table of Figures
automatically is inserted below the TOT, however if there
is no TOT, then the TOF goes under the TOC.

At the moment everything works unless the bookmarks get
deleted.

The easy solution is don't delete the bookmarks, but life
isn't easy

Appreciate any suggestions
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Samurai > écrivait :
In this message, < Samurai > wrote:

|| I have Document Template that contains a Table of
|| Contents. I have a couple of Macros that insert Tables of
|| Tables and Tables of Figures. The Macros look for 2

How is your code invoked? Is it run by the user clicking on some button? Or
by the Document_Open event...?

|| bookmarks. One bookmark is stored at the end of the Table
|| of Contents field, so that the Table of Tables always
|| ends up in the right place and can't be deleted by
|| mistake. The problem is the 2nd bookmark keeps getting
|| deleted if I delete the Table of Figures and the Table of
|| Tables.
||
|| Also, if I were to delete the Table of Contents, then the
|| Table of Table bookmark would disappear.

Would the TOC get deleted by your macros or by the user? If the user, why
would he/she delete the TOC?

|| What I need to do is be able to insert the Table of
|| Contents in a certain place, if it gets deleted and then
|| insert the other 2 tables after it. For example, if the
|| Table of Tables is there, then the Table of Figures
|| automatically is inserted below the TOT, however if there
|| is no TOT, then the TOF goes under the TOC.
||
|| At the moment everything works unless the bookmarks get
|| deleted.

How does the bookmarks get deleted? Do you mean manually by the user while
working in the document?

|| The easy solution is don't delete the bookmarks, but life
|| isn't easy
||

It is always tricky to write code that relies on Bookmarks that are in a
part of the text that the user can delete. If the user can easily delete the
bookmarks, then don't use them!

Have you looked in the possibility of placing your TOT and TOF after the TOC
by using
ActiveDocument.TablesOfContents(1).Range
or
ActiveDocument.TablesOfFigures(1).Range
and so on?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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