TOC does not format correctly

M

Mikel

I am new to Word and VBA. We are upgrading from Word 97 to
Word 2000 and most of our macros convert beautifully. In
Word 2000 I have tried inserting a Table of Contents
manually and by using our existing word 97 macro. In both
cases the TOC comes in formatted exactly like the text is
formatted inside the document and not how the TOC 1-3 is
formated within the Insert, Index and Tables, Table of
Content, Styles dialog box show the TOC 1-3 to be
formatted. I have gone as far as changing the font after
the TOC is inserted. I can do this manually but the
recorder doesn't let me record the keystrokes and I want
to automate it. Thanks in advance for any suggestions.
 
D

Dave Lett

I would try changing the style definition for TOC 1-3 and then update the field. Also, make sure that you're using the \* MERGEFORMAT switch in the field code.

HTH,
Dave
 
C

Cindy M -WordMVP-

Hi Mikel,

I think you need to back up a step here and find out WHY the
formatting is not correct. In my experience, if the TOC
styles are being overridden by formatting in the document,
this is a sign that the document text was formatted directly,
rather than with a style.

So, in a copy of the document, let's try:
- Ctrl+A
- Ctrl+Spacebar (this will remove all direct formatting and
all character styles)
- Update the TOC

Do you see the TOC styles now?
I am new to Word and VBA. We are upgrading from Word 97 to
Word 2000 and most of our macros convert beautifully. In
Word 2000 I have tried inserting a Table of Contents
manually and by using our existing word 97 macro. In both
cases the TOC comes in formatted exactly like the text is
formatted inside the document and not how the TOC 1-3 is
formated within the Insert, Index and Tables, Table of
Content, Styles dialog box show the TOC 1-3 to be
formatted. I have gone as far as changing the font after
the TOC is inserted. I can do this manually but the
recorder doesn't let me record the keystrokes and I want
to automate it.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep
30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?RGF2ZSBMZXR0?=,
Also, make sure that you're using the \* MERGEFORMAT switch in the field code.
I think that would be a big mistake, but maybe I don't know something special
about how this switch works in a TOC field. The way this switch works is to
retain direct formatting applied to field content. I see two problems, though,
in connection to the stated question:

1. This will still mask the TOC styles

2. If the content of the TOC changes (more or fewer characters), the formatting
will no longer be applied to the correct characters. \* MergeFormat formatting
is location-linked.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
M

Mikel

Yes, I see the TOC styles now. You are correct the text
is formatted directly because we want it to stand out from
the rest of the text. How do I retain the formatting in
document and still have the TOC format correctly. We were
able to do this with Word 97.
 
C

Cindy M -WordMVP-

Hi Mikel,
Yes, I see the TOC styles now. You are correct the text
is formatted directly because we want it to stand out from
the rest of the text. How do I retain the formatting in
document and still have the TOC format correctly. We were
able to do this with Word 97.
Define CHARACTER styles and use these to apply formatting
"over" the paragraph style formatting. The TOC will drop any
formatting applied via a character style.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep
30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 

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