TOC

C

cll

Hi all,

I have a weird problem with TOC
The following (simplified) code put a TC field and make a
TOC from that:

Private Sub TabCon()

Selection.HomeKey unit:=wdStory

ActiveDocument.TablesOfContents.MarkEntry
Range:=Selection.Range, _
Entry:="text1" & Chr(9) & "text2" & Chr(9) & "text3",
TableID:="P"

Selection.EndKey unit:=wdStory

ActiveDocument.TablesOfContents.Add
Range:=Selection.Range, UseFields:=True, _
UseHeadingStyles:=False, TableID:="P"

End Sub

While the TC field is inserted with tabulations:

{ TC "text1(tab)text2(tab)text3" \f P \l "1" }

where (tab) is the tabulation mark, the TOC is inserted
only with the first tabulation (and tabulation for page)
the second tabulation become a space:

text1(tab)text2 text3(tab)1
Field: { TOC \f P }

Can anyone explain it to me and/or solve the problem I
would greately appreciate that - thanks!

Regards
cll
 
C

Cindy M -WordMVP-

Hi Cll,

This is the way the TOC field is designed to work by
default. In more recent versions of Word, the \w switch was
added that is supposed to retain TAB characters. You might
try including that. If there's no option for specifying the
switches with the Add method of the TableOfContents object,
try inserting the TOC field explicitly using the Add method
of the FIELDS object, instead. You can specify any switches
as part of the TEXT argument.
I have a weird problem with TOC
The following (simplified) code put a TC field and make a
TOC from that:

Private Sub TabCon()

Selection.HomeKey unit:=wdStory

ActiveDocument.TablesOfContents.MarkEntry
Range:=Selection.Range, _
Entry:="text1" & Chr(9) & "text2" & Chr(9) & "text3",
TableID:="P"

Selection.EndKey unit:=wdStory

ActiveDocument.TablesOfContents.Add
Range:=Selection.Range, UseFields:=True, _
UseHeadingStyles:=False, TableID:="P"

End Sub

While the TC field is inserted with tabulations:

{ TC "text1(tab)text2(tab)text3" \f P \l "1" }

where (tab) is the tabulation mark, the TOC is inserted
only with the first tabulation (and tabulation for page)
the second tabulation become a space:

text1(tab)text2 text3(tab)1
Field: { TOC \f P }

Can anyone explain it to me and/or solve the problem I
would greately appreciate that - thanks!

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