Toc keeps picking up heading-styles

R

rVo

I've recorded a macro while creating a TOC from a booksize document, I
included only 3 styles and no heading-styles.
The TOC looks perfect after creating it. When I try to create it again using
the recorded macro I always get the heading 1, 2 and 3 which are also
available in the document in my TOC although they should not be there.

Is this a bug concerning VBA?
Do I have to add something to the code in order to avoid this? Or should I
remove the heading styles from the document?

Thanks for your time/help...

rVo
 
D

Dawn Crosier

You might want to post your code so we can see the steps you included
in your recording.

--
Dawn Crosier
Microsoft MVP
"Education Lasts a Lifetime"

This message is posted to a newsgroup. Please post replies and
questions to the newsgroup so that others can learn as well.
 
J

Jay Freedman

I've recorded a macro while creating a TOC from a booksize document, I
included only 3 styles and no heading-styles.
The TOC looks perfect after creating it. When I try to create it again using
the recorded macro I always get the heading 1, 2 and 3 which are also
available in the document in my TOC although they should not be there.

Is this a bug concerning VBA?
Do I have to add something to the code in order to avoid this? Or should I
remove the heading styles from the document?

Thanks for your time/help...

rVo

Have a look at
http://www.word.mvps.org/FAQs/Formatting/TOCSwitches.htm. Compare what
you see there and in the Help article on "TOC field switches" --
particularly the \o and \t switches -- to what's in the field code of
the TOC field your macro creates. If you still can't figure it out,
post your macro code and the resulting field code in a reply here.

Also, be aware that the macro recorder sometimes gets things wrong,
and the macro needs to be edited. See
http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
R

rVo

I've figured out a workaround now. I manually create the field code instead
of using the recorded macro.

While recording the macro i get a Toc-field containing the code: {TOC \h \z
\t "Style1; 1;Style2;2;Style3;3"}
and this is perfect.

When I rerun the code from the recorded macro the Toc-field wil contain the
code {TOC \o "1-9" \h \z \t "Style3;3;Style1;1;Style2;2"}

If you really want me to post the generated code I will do it, but our
firewall is very suspicious so I'll have to modify the code in order to get
it out. Sorry for that.

Thanks for your time/help...

rVo
 

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