Hi Julie,
try collapsing the range to it's end in any case.
Means:
if [...] then
[...]
rDcm.collapse direction:=wdcollapseend
elseif
[...]
rDcm.collapse direction:=wdcollapseend
elseif
[...]
rDcm.collapse direction:=wdcollapseend
Endif
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
>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."
[quoted text clipped - 31 lines]
> End With
> ResetSearch
singeredel - 18 Mar 2005 19:58 GMT
Hi Helmut,
Thanks again for your help. That indeed moved the selection to the next
incident of the word, but now it is in a continual loop of finding the word
"patient" and never finishes.
> Hi Julie,
> try collapsing the range to it's end in any case.
[quoted text clipped - 52 lines]
> > End With
> > ResetSearch
Hi Julie,
instead of discussing all, forgive me, mistakes and
logical twists and missing or redunandant code,
I thought, it would be better to start anew.
When using and and select the range,
it might be advisable, to avoid range at all
and use selection from the beginning.
Like this:
Sub test55555()
Dim lRsl As Long ' Result from Msgbox
Dim sQus As String ' Question
sQus = "Change 'patient' to 'claimant'?"
' vbYesNo '4
' vbQuestion ' 32
' sum = 36
lRsl = MsgBox(sQus, 36, "Patient to Claimant")
If lRsl = vbNo Then Exit Sub
ResetSearch
With Selection
.WholeStory
.Collapse
With .Find
.Text = "patient"
.MatchCase = True
.MatchWholeWord = True
While .Execute
lRsl = MsgBox(sQus, 36, "Change")
If lRsl = vbYes Then
Selection.Text = "claimant"
End If
Selection.Collapse direction:=wdCollapseEnd
Wend
End With
.WholeStory
.Collapse
End With
ResetSearch
End Sub
HTH
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
singeredel - 22 Mar 2005 00:27 GMT
Hi Helmut,
Thanks for coming to my rescue again. I have one problem with this code. The
word to be changed is not selected, so I cannot see what word is being
addressed at any particular time. Also, can you explain what "vbYesNo 4" and
"vbQuestion 32", "sum = 36" is about? Thanks.
Julie
> Hi Julie,
> instead of discussing all, forgive me, mistakes and
[quoted text clipped - 48 lines]
> Word XP, Win 98
> http://word.mvps.org/
singeredel - 22 Mar 2005 01:01 GMT
Helmut,
Please ignore my last post regarding not seeing the selection. I see what
has happened. The first message box probably doesn't need to be included.
However, I would still like to know what the 36 is all about in the message
box. Thanks again for your help!
> Hi Julie,
> instead of discussing all, forgive me, mistakes and
[quoted text clipped - 48 lines]
> Word XP, Win 98
> http://word.mvps.org/
Helmut Weber - 22 Mar 2005 04:35 GMT
Hi Julie,
instead of
msgbox [...], vbYesNo + vbQuestion, [...]
you could write
msgbox [...], 4 + 32, [...]
and instead of that you could add the values
msgbox [...], 36, [...]
which makes a single line of code harder to read,
but because of the short lines, I think, the code
altogether is easier to understand.
From my point of view.
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Helmut Weber - 22 Mar 2005 05:07 GMT
...and besides that all,
note that the messagebox may appear
over the selected word and hide it.