It's a range.
oField.Code.Text = "TOC etc." should do it, or specify the text when you
invoke oDoc.Fields.Add
--
Peter Jamieson - Word MVP
Word MVP web site http://word.mvps.org/
It's something like that I tried, but I can't seem to
copy the content back into the field, I get a "type
mismatch" error when assigning a string to Field.Code.
What kind of data should it be?
>-----Original Message-----
>There are two basic problems with merging a TOC:
> a. the TOC field is lost - at best, you will see a copy
of the /result/ of
>the TOC field, possibly including Hyperlinks
(each "copy" of the TOC will
>convert to exactly the same text and destination
bookmarks)
> b. all bookmarks are in any case lost, so any
hyperlinks wil point to
>non-existent destinations.
>
>However, since paragraph styles and TC fields are both
preserved, you could
>re-insert the necessary TOC field(s) after the merge
(perhaps use some
>placeholder text or a field that survies the merge to
tell you where to put
>the TOC), then refresh the document fields. This is
obviously easier if you
>know what type of TOC field should be in there - if you
are trying to write
>a generic mailmerger so that anyone's TOC survives the
process, you would
>probably have to use VB to
> a. get the existing TOC field code
> b. replace the TOC by placeholder text or whatever
> c. proceed as above. You would probably also need to
know whether th user
>wanted one TOC, or one TOC per section , in the final
output.
>--
>Peter Jamieson - Word MVP
[quoted text clipped - 3 lines]
>> I have a VB6 program that performes a MailMerge.
>> But if my template contains a Table of contents, it
will
>> loose all references when merged.
>> I read something about problem with FormFields in the
>> knowledgebase article Q211308, but I can't make it
work.
>> The solution was to loop through all FormFields and
store
>> them temporary, and restore them after the MailMerge.
>>
[quoted text clipped - 4 lines]
>
>.