Hi Guys
Im new to coding in word i have an issue im trying to set up a loop that will find a section of text carry out a process, the issue i have is looping until the search text can't be found, I have set the start of the loop to Selection.Find.Found = False, this seems to stop the loop starting
Sub FindSNO()
Selection.HomeKey Unit:=wdStory
Do Until Selection.Find.Found = False
Selection.Find.ClearFormatting
With Selection.Find
.Text = "RFF+SNO'"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=2
Selection.MoveRight Unit:=wdCharacter, Count:=8, Extend:=wdExtend
If Selection = "RFF+IFN:" Then
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=8
Selection.MoveRight Unit:=wdCharacter, Count:=6, Extend:=wdExtend
Selection.Copy
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=8
Selection.MoveUp Unit:=wdLine, Count:=2
Selection.MoveRight Unit:=wdCharacter, Count:=7
Selection = ":"
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Paste
Selection.MoveLeft Unit:=wdCharacter, Count:=14
strError = strError & "RFF+SNO' Error " & Selection.Range.Information(wdActiveEndPageNumber) & "-" & Selection.Range.Information(wdFirstCharacterLineNumber) & ", "
End If
Loop
End Sub
Im new to coding in word i have an issue im trying to set up a loop that will find a section of text carry out a process, the issue i have is looping until the search text can't be found, I have set the start of the loop to Selection.Find.Found = False, this seems to stop the loop starting
Sub FindSNO()
Selection.HomeKey Unit:=wdStory
Do Until Selection.Find.Found = False
Selection.Find.ClearFormatting
With Selection.Find
.Text = "RFF+SNO'"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=2
Selection.MoveRight Unit:=wdCharacter, Count:=8, Extend:=wdExtend
If Selection = "RFF+IFN:" Then
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=8
Selection.MoveRight Unit:=wdCharacter, Count:=6, Extend:=wdExtend
Selection.Copy
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=8
Selection.MoveUp Unit:=wdLine, Count:=2
Selection.MoveRight Unit:=wdCharacter, Count:=7
Selection = ":"
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Paste
Selection.MoveLeft Unit:=wdCharacter, Count:=14
strError = strError & "RFF+SNO' Error " & Selection.Range.Information(wdActiveEndPageNumber) & "-" & Selection.Range.Information(wdFirstCharacterLineNumber) & ", "
End If
Loop
End Sub