help with macro please

S

simmo

Hi all,

Any help would be appreciated
I am trying to get this macro to run to the end of the word document
then stop.

But it keeps on looping

Without the loop command it will only do what I want once


Do Until Selection.HomeKey

Selection.HomeKey Unit:=wdLine

Selection.Find.ClearFormatting
With Selection.Find
.Text = "FD"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False

Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=2
Selection.MoveRight Unit:=wdCharacter, Count:=4, Extend:=wdExtend
Selection.Shading.Texture = wdTextureNone
Selection.Shading.ForegroundPatternColor = wdColorAutomatic
Selection.Shading.BackgroundPatternColor = wdColorLightYellow
Selection.Shading.Texture = wdTextureNone
Selection.Shading.ForegroundPatternColor = wdColorAutomatic
Selection.Shading.BackgroundPatternColor = wdColorLightYellow
Selection.MoveRight Unit:=wdCharacter, Count:=1
End With

Loop



End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top