Article ID: 204433
Article Last Modified on 6/17/2005
{XE "text"} or {TC "text"}
212536 OFF2000: How to Run Sample Code from Knowledge Base Articles
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
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