N
n6trf
I have the following macro which i use to check for duplicate entries in a
document. what i do not understand is, when I remove the second 'with
selection.find ... end with' then the 3rd time I execute
selection.find.execute I get no movement of the cursor. I assumed the 'with
selection.find ... end with' would apply to all the selection.find.executes.
Help please
With Selection.Find
' .Text = Selection()
.Text = strTem
.Replacement.Text = ""
.Forward = True
' .Wrap = wdFindAsk
' .Wrap = wdFindStop
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
If vbCancel = MsgBox("Thats once", vbOKCancel) Then Exit Sub
Selection.Find.Execute
If vbCancel = MsgBox("Thats twice: We should NOT be in the list again",
vbOKCancel) Then Exit Sub
' Selection.MoveRight Unit:=wdCharacter, Count:=2
With Selection.Find
' .Text = Selection()
.Text = strTem
.Replacement.Text = ""
.Forward = True
' .Wrap = wdFindAsk
' .Wrap = wdFindStop
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
If vbCancel = MsgBox("Thats thrice: We should BE in the list again",
vbOKCancel) Then Exit Sub
document. what i do not understand is, when I remove the second 'with
selection.find ... end with' then the 3rd time I execute
selection.find.execute I get no movement of the cursor. I assumed the 'with
selection.find ... end with' would apply to all the selection.find.executes.
Help please
With Selection.Find
' .Text = Selection()
.Text = strTem
.Replacement.Text = ""
.Forward = True
' .Wrap = wdFindAsk
' .Wrap = wdFindStop
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
If vbCancel = MsgBox("Thats once", vbOKCancel) Then Exit Sub
Selection.Find.Execute
If vbCancel = MsgBox("Thats twice: We should NOT be in the list again",
vbOKCancel) Then Exit Sub
' Selection.MoveRight Unit:=wdCharacter, Count:=2
With Selection.Find
' .Text = Selection()
.Text = strTem
.Replacement.Text = ""
.Forward = True
' .Wrap = wdFindAsk
' .Wrap = wdFindStop
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
If vbCancel = MsgBox("Thats thrice: We should BE in the list again",
vbOKCancel) Then Exit Sub