WD: Incorrect Formatting in Index or Table of Contents

ID: Q123057

The information in this article applies to:

SYMPTOMS

Direct (or manual) formatting, such as bold or underline formats, applied to XE or TC fields are carried over to the table of contents and the index field results.

WORKAROUNDS

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/supportnet/refguide/ 

To avoid this problem, reset the XE or TC fields to the default formatting. To do this, use any of the following methods.

Method 1:

Select the XE or TC field and press CTRL+SPACEBAR. This forces the character formatting to return to the default of the current style.

Method 2:

Use a macro to automate this process. The following macro resets each of the XE fields in the document. Use this macro to reset direct formatting that affects your index.

          Sub MAIN
          Dim TOV As ToolsOptionsView
          GetCurValues TOV
          If TOV.ShowAll = 0 Then
             ToolsOptionsView .ShowAll = 1
             Change$ = "yes"
          End If
          EditBookmark .Name = "ClearFormats", .Add
          StartOfDocument
          EditFind .Find = "^d XE", .Direction = 0, .MatchCase = 0,
          .WholeWord = 0, .PatternMatch = 0, .SoundsLike = 0, .Format =
          0, .Wrap = 1
          While EditFindFound()
             ResetChar
             EditFind
          Wend
          StartOfDocument
          EditFind .Find = "^dXE", .Direction = 0, .MatchCase = 0,
          .WholeWord = 0, .PatternMatch = 0, .SoundsLike = 0, .Format =
          0, .Wrap = 1
          While EditFindFound()
             ResetChar
             EditFind
          Wend
          EditSelectAll
          UpdateFields
          EditGoTo .Destination = "ClearFormats"
          If Change$ = "yes" Then ToolsOptionsView .ShowAll = 0
          End Sub

Method 3:

Use the following macro to remove the direct formatting applied to each of the TC fields and then update the table of contents:

          Sub MAIN
          Dim TOV As ToolsOptionsView
          GetCurValues TOV
          If TOV.ShowAll = 0 Then
             ToolsOptionsView .ShowAll = 1
             Change$ = "yes"
          End If
          EditBookmark .Name = "ClearFormats", .Add
          StartOfDocument
          EditFind .Find = "^d TC", .Direction = 0, .MatchCase = 0,
          .WholeWord = 0, .PatternMatch = 0, .SoundsLike = 0, .Format =
          0, .Wrap = 1
          While EditFindFound()
             ResetChar
             EditFind
          Wend
          StartOfDocument
          EditFind .Find = "^dTC", .Direction = 0, .MatchCase = 0,
          .WholeWord = 0, .PatternMatch = 0, .SoundsLike = 0, .Format =
          0, .Wrap = 1
          While EditFindFound()
             ResetChar
             EditFind
          Wend
          EditFind .Find = "^19 toc"
          SendKeys "{F9}%e{enter}"
          EditGoTo .Destination = "ClearFormats"
          If Change$ = "yes" Then ToolsOptionsView .ShowAll = 0
          End Sub

STATUS

We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

For additional information on how manual formatting affects your table of contents when using styles, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q122706
   TITLE     : Table of Contents Shows Wrong Formatting

Additional query words: fields macros toc index update updating xe tc direct manual format formatting
Keywords          : wordnt kbmacroexample kbfield winword ntword macword word6 word7 word95 kbformat 
Version           : WINDOWS: 6.0, 7.0; MACINTOSH: 6.0, 6.0.1
Platform          : MACINTOSH WINDOWS
Issue type        : kbprb

Last Reviewed: April 9, 1999