Microsoft KB Archive/70996

{|
 * width="100%"|

WD: Macro to Create Table of Contents Entry Automatically

 * }

Q70996

-

The information in this article applies to:


 * Microsoft Word for Windows, versions 1.0, 1.1, 1.1a, 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
 * Microsoft Word for Windows 95, versions 7.0, 7.0a

-

SUMMARY
The following macro examples allow you to designate selected text as a table of contents entry without removing the text from the body of the document. You do not have to type the table of contents entry twice.

MORE INFORMATION
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code &quot;as is&quot; without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

You can assign the following macro to a menu, toolbar, or a key sequence to quickly designate text to be included in a table of contents:

  Sub MAIN a$ = Selection$ CharRight 1 InsertFieldChars Insert &quot;tc &quot; + Chr$(34) + a$ + Chr$(34) CharRight 1 End Sub When you have designated all of the table of contents entries with this macro, choose Table Of Contents from the Insert menu and select Use Table Entry Fields.

Table of Contents entries or TC fields are automatically formatted as hidden text. To edit these entries, you must select either Show All or Hidden Text. In Word versions 6.x and 7.x, choose Options from the Tools menu, then choose Field Codes from the View tab. Click the Hidden Text check box to select it. In Word version 2.0 for Windows, choose Options from the Tools menu. Select the View category and mark the Hiddent Text check box. In Word version 1.0 for Windows, choose Preferences from the View menu and mark the Show All check box.

Additional query words: 1.x 2.0 word6 7.0 word95 winword winword2

Keywords : kbmacro kbmacroexample kbfield

Issue type : kbhowto

Technology : kbWordSearch kbWord700Search kbZNotKeyword2 kbWord600 kbWord600a kbWord600c kbWord200 kbWord200a kbWord200b kbWord200c kbWord100 kbWord110 kbWord700 kbWord110a kbWord700a