> WordPerfect used to automatically quit the macro when it couldn't find the
> search criteria anymore. Can Word do the same thing? Tried to do a loop
[quoted text clipped - 14 lines]
> Selection.MoveLeft Unit:=wdCharacter, Count:=1
> Selection.Fields.ToggleShowCodes
Try this:
Dim rgeFind As Range
Set rgeFind = ActiveDocument.Range
With rgeFind.Find
.Text = "*#*"
.Forward = True
.Wrap = wdFindStop
Do While .Execute
With .Parent
rgeFind.Fields.Add Range:=rgeFind, Type:=wdFieldEmpty, _
Text:="Macrobutton nomacro [Keyboard]", _
PreserveFormatting:=False
End With
Loop
End With
Try not to use the Selection object. From the code you posted, I assume you
used the recorder, which always uses the Selection object. See these links
for more on taming the recorder results...
http://word.mvps.org/faqs/macrosvba/UsingRecorder.htm
http://word.mvps.org/faqs/macrosvba/ModifyRecordedMacro.htm
Brenda A. Reid - 25 Feb 2008 18:16 GMT
Thanks a mill - working great.
>> WordPerfect used to automatically quit the macro when it couldn't find
>> the
[quoted text clipped - 42 lines]
> http://word.mvps.org/faqs/macrosvba/UsingRecorder.htm
> http://word.mvps.org/faqs/macrosvba/ModifyRecordedMacro.htm