Microsoft KB Archive/204433

From BetaArchive Wiki

Article ID: 204433

Article Last Modified on 6/17/2005



APPLIES TO

  • Microsoft Word 2000 Standard Edition



This article was previously published under Q204433


SYMPTOMS

When you apply direct (or manual) formatting, (for example: bold, italic, or underline), to text that contains either an XE or TC field, the direct formatting may be carried over to either the index or the table of contents field results.

WORKAROUND

Use one of the following methods to work around this problem.

Method 1: Remove the Direct Formatting Manually

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

To select an XE or TC field, follow these steps:

  1. On the Tools menu, click Options.
  2. On the View tab, click to select All and then click OK.
  3. Select the XE or TC field from which you want to remove the direct formatting.

    NOTE: Your XE or TC field should look similar to one of the following examples:

    {XE "text"} or {TC "text"}

  4. With the XE or TC field selected, press CTRL+SPACEBAR.
  5. Repeat steps 3-4 for each XE or TC field that you want to remove direct formatting from.
  6. Update your table of contents or index. To do this, select either the table of contents or index and press F9.

Method 2: Use a Macro to Remove the Direct Formatting from Index (XE) Fields

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers 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 requirements.
For more information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:

212536 OFF2000: How to Run Sample Code from Knowledge Base Articles



Use the following macro to remove the direct formatting applied to each of the XE fields and then update the index:

Sub ClearXEFormats()

   ' Turn the Show All option on.
   If ActiveWindow.View.ShowAll = False Then
      ActiveWindow.View.ShowAll = True
   End If

   ' Start at the top of the document.
   Selection.HomeKey Unit:=wdStory, Extend:=wdMove

   ' Find the Index Entry fields.
   With Selection.Find
      Do While .Execute(FindText:="^d XE", Forward:=True, _
      Format:=True) = True
         ' Reset the font selections.
         Selection.Font.Reset
      Loop
   End With
 
    ' Start at the top of the document.
   Selection.HomeKey Unit:=wdStory, Extend:=wdMove
 
    ' Turn the Show Field Codes option on.
   If ActiveWindow.View.ShowFieldCodes = False Then
      ActiveWindow.View.ShowFieldCodes = True
   End If
 
   ' Find the Index field.
   With Selection.Find
      Do While .Execute(FindText:="^d INDEX", Forward:=True, _
      Format:=True) = True
         ' Reset the font selections.
         Selection.Font.Reset
      Loop
   End With

   ' Turn the Show Field Codes option off.
   If ActiveWindow.View.ShowFieldCodes = True Then
      ActiveWindow.View.ShowFieldCodes = False
   End If

   ' Turn the Show All option off.
   If ActiveWindow.View.ShowAll = True Then
      ActiveWindow.View.ShowAll = False
   End If

   ' Move the insertion point to unselect the document text.
   Selection.MoveRight

End Sub
                

Method 3: Use a Macro to Remove Direct Formatting from Table of Contents Entries (TC) Fields

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

Sub ClearTCFormats()

   ' Turn the Show Field Codes option on.
   If ActiveWindow.View.ShowFieldCodes = False Then
      ActiveWindow.View.ShowFieldCodes = True
   End If
   
      ' Turn the Show All option on.
   If ActiveWindow.View.ShowAll = False Then
      ActiveWindow.View.ShowAll = True
   End If

   ' Start at the top of the document.
   Selection.HomeKey Unit:=wdStory, Extend:=wdMove

   ' Find the Index Entry fields.
   With Selection.Find
      Do While .Execute(FindText:="^d TC", Forward:=True, _
      Format:=True) = True
         ' Reset the font selections.
         Selection.Font.Reset
      Loop
   End With
 
   ' Start at the top of the document.
   Selection.HomeKey Unit:=wdStory, Extend:=wdMove

   ' Update the TOC field in the entire document.
   With Selection.Find
      Do While .Execute(FindText:="^d TOC", Forward:=True, _
      Format:=True) = True
         ' Reset the font selections.
         Selection.Font.Reset
      Loop
   End With

   ' Turn the Show All option off.
   If ActiveWindow.View.ShowAll = True Then
      ActiveWindow.View.ShowAll = False
   End If

   ' Turn the Show Field Codes option off.
   If ActiveWindow.View.ShowFieldCodes = True Then
      ActiveWindow.View.ShowFieldCodes = False
   End If

   ' Move the insertion point to unselect the document text.
   Selection.MoveRight

End Sub
                

Keywords: kbformat kbmacroexample kbprb kbfield KB204433