J
Jon
I have a macro which is designed to find an occurrence of a string of text,
copy it to a variable, and add some XML tags containing that variable. I
then want it to repeat the process down the document to find the next
occurrence and so on. How can I write a loop that will stop when it reaches
the last occurrence in the document?
The part that I want to loop follows:
Thanks,
Jon.
Selection.Find.ClearFormatting
With Selection.Find
.Text = "<title>"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Extend
Selection.Extend Character:="<"
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Title = LCase(Selection)
Selection.Collapse (wdCollapseEnd)
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="<indexterm><index1>"
Selection.InsertBefore Title
Selection.Collapse (wdCollapseEnd)
Selection.TypeText Text:="</index1><index2>"
Selection.InsertBefore Keyword
Selection.Collapse (wdCollapseEnd)
Selection.TypeText Text:="</index2></indexterm><"
copy it to a variable, and add some XML tags containing that variable. I
then want it to repeat the process down the document to find the next
occurrence and so on. How can I write a loop that will stop when it reaches
the last occurrence in the document?
The part that I want to loop follows:
Thanks,
Jon.
Selection.Find.ClearFormatting
With Selection.Find
.Text = "<title>"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Extend
Selection.Extend Character:="<"
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Title = LCase(Selection)
Selection.Collapse (wdCollapseEnd)
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="<indexterm><index1>"
Selection.InsertBefore Title
Selection.Collapse (wdCollapseEnd)
Selection.TypeText Text:="</index1><index2>"
Selection.InsertBefore Keyword
Selection.Collapse (wdCollapseEnd)
Selection.TypeText Text:="</index2></indexterm><"