TC
- 2 minutes to read
Non-MailMerge field
{ TC “entry text” [ switches ] }
Specifies the text and page number for a table of contents entry, which is used by a TOC.
The TC field supports the following switches:
Switch | Description |
---|---|
\f identifier | The type of items collected in a particular contents list. Use a unique type identifier for each type of list. This switch is required for including into corresponding TOC. |
\l “level number” | The level of the TC entry. If no level is specified, level 1 is assumed. |
using (var wordProcessor = new RichEditDocumentServer()) {
wordProcessor.LoadDocument("Documents//Table of Contents.docx");
int j = 1;
// Mark every chapter title in the document by the TC field
for (int i = 0; i < wordProcessor.Document.Paragraphs.Count; i++) {
string var = wordProcessor.Document.GetText(wordProcessor.Document.Paragraphs[i].Range);
if (var.Contains("CHAPTER ")) {
Field field = wordProcessor.Document.Fields.Create(wordProcessor.Document.Paragraphs[i].Range.Start, String.Format("TC {0} \\f bvz ", j));
wordProcessor.Document.Fields.Update();
j++;
}
}
}