Use the Selection.InsertAutotext command after selecting the text that
represents the name of the autotext item that you want to replace it with..
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
I recorded and edited a "find and replace" macro to come up with the
following code:
Sub Replace_U()
'
' Replace (U) with Unclassified AutoText
' Macro written 5/11/2009 by John Cupak
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "(U)"
.Replacement.Text = "(U) " <-- This SHOULD be the autotext
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
NormalTemplate.AutoTextEntries("Unclassified").Insert
Where:=Selection.Range, RichText:=True
End Sub
Unfortunately, it requires me to search for each classification
marking manually, as the macro works by finding, deleting, then
inserting the autotext.
I know that I could insert the autotext directly:
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
PreserveFormatting:=False
Selection.TypeText Text:="QUOTE (S) "
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
PreserveFormatting:=False
Selection.TypeText Text:="SEQ S \r"
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
PreserveFormatting:=False
Selection.TypeText Text:="PAGE"
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.TypeText Text:="\h"
But this seems like a lot of work.
Isn't there an easier way to find and replace ALL the classification
markings? (Of course, "(U)" is only 1 of 3 markings).