Help with TOC

A

Associates

Hi,

I am having problem with TOC in word document (office 03). I was wondering
if anyone might be able to help me out.

The following is what i have in TOC

Preface..................................1
Introduction............................2
Chapter 1 xxxxx......................3
....
Bibliography 4
Abbreviation 5

The way i added those two sections (Bibliography and Abbreviation) is
through the use of the following code

Selection.TypeText myStr
Selection.Style = ActiveDocument.Styles("Doument Heading 1")
Call UpdateTOC

In the UpdateTOC sub, i have
Sub UpdateTOC()

Application.ScreenUpdating = False
Dim toc As TableOfContents

For Each toc In ActiveDocument.TablesOfContents
toc.Update
Next

End Sub


In the document itself, i have "Doument Heading 1" style set up. However,
don't know if i have set the style up incorrectly. Would i be able to get
some help here?

Thank you in advance
 
A

Associates

Thank you Stefan for your reply.

What happens is that i have a template that would allow users to create or
generate a standard report document to be submitted to clients.

The report is made up of a several sections in the following orders
Preface
Introduction
Executive Summary
Section/Chapter 1...
Glossary
Appendix

So, when user runs the template, a userform pops up and allows them to
select which one of those sections they want to include in the report. The
way they are inserted into the report is using autotexts. In the template
itself, i have made up a few styles that are the same as required by the
autotexts.

However, then i started to think that there may be a situation in which user
would like to add their own sections that are not of the list in the
userform. For example, the following is what has been inserted into the
report after running the template.

Preface
Introduction
Section 1. blah blah
Section 2. blah blah
2.1 blah blah
....
Glossary
Appendix

If the user wants to add another new section between Glossary and Appendix
namely "Abbreviation", they should be allowed to do that. Hence, i created a
macro that allows them to do so by using the codes that i indicated in my
earlier thread. Note, Preface, Introduction and Glossary use a style called
"Doument Heading 1". Section 1 uses style of "Section Heading 1".

However, when the macro was run and added the "Abbreviation" to the report,
i went to update field in the TOC. The result was as follows

Preface..................................1
Introduction............................2
Section 1 xxxxx.......................3
...
Glossary................................ 4
Abbreviation 5

There was no tab to the Abbreviation like all the others. I wonder if you
could tell me what is wrong with that.

Thank you in advance
 
S

Stefan Blom

Which TOC level was assigned to "Abbrevation"? Check the corresponding TOC
style to make sure it has a right-aligned tab stop with a leader defined.
 
A

Associates

Thank you Stefan for your reply.

Yes it works now. As soon as i set a certain number to the tab with a leader
defined, it works.

Thank you
 

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