S
singeredel
The purpose of the following code is to find every instance of the word
"patient" and ask whether the word should be changed to "claimaint."
Everything seems to work fine except when "vbNo" is selected. At this point
the program does not cycle to the next instance of the word "patient" but
just continues to remain at the current selection point in a continual loop.
Can anyone tell me what is wrong and what further code may be necessary to
find the next instance of the word "patient?"
Thanks!
ChangePatientToClaimant:
ResponsePatientToClaimant = MsgBox("Do you want to change instances of
the word 'patient' to 'claimant'?", vbYesNo + vbQuestion + vbDefaultButton1,
"ChangePatientToClaimant")
Dim oRng As Range
ResetSearch
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "patient"
.Wrap = wdFindContinue
.MatchCase = True
.MatchWholeWord = True
While .Execute
oRng.Select
ResponseMsgBox = MsgBox("Change 'patient' to 'claimant'?",
vbYesNoCancel + vbQuestion + vbDefaultButton1, "Change")
If ResponseMsgBox = vbYes Then
oRng.Text = "claimant"
ElseIf ResponseMsgBox = vbNo Then GoTo Continue
ElseIf ResponseMsgBox = vbCancel Then GoTo DeleteMarks
End If
Continue:
Wend
End With
ResetSearch
"patient" and ask whether the word should be changed to "claimaint."
Everything seems to work fine except when "vbNo" is selected. At this point
the program does not cycle to the next instance of the word "patient" but
just continues to remain at the current selection point in a continual loop.
Can anyone tell me what is wrong and what further code may be necessary to
find the next instance of the word "patient?"
Thanks!
ChangePatientToClaimant:
ResponsePatientToClaimant = MsgBox("Do you want to change instances of
the word 'patient' to 'claimant'?", vbYesNo + vbQuestion + vbDefaultButton1,
"ChangePatientToClaimant")
Dim oRng As Range
ResetSearch
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "patient"
.Wrap = wdFindContinue
.MatchCase = True
.MatchWholeWord = True
While .Execute
oRng.Select
ResponseMsgBox = MsgBox("Change 'patient' to 'claimant'?",
vbYesNoCancel + vbQuestion + vbDefaultButton1, "Change")
If ResponseMsgBox = vbYes Then
oRng.Text = "claimant"
ElseIf ResponseMsgBox = vbNo Then GoTo Continue
ElseIf ResponseMsgBox = vbCancel Then GoTo DeleteMarks
End If
Continue:
Wend
End With
ResetSearch