Re: Word 2003 Find/Replace Doesn't Ignore Deleted Text by Russ
Russ
Sat Sep 09 16:42:16 CDT 2006
Oops,
>
>
>
>
>
>> To make F&R ignore deleted text you need to make it hidden, something like
>> this ...
>>
>> Dim DeletedTextOption As WdDeletedTextMark
>>
>> ' Save the current user setting
>> DeletedTextOption = Options.DeletedTextMark
>> ' Override it with Hidden
>> Options.DeletedTextMark = wdDeletedTextMarkHidden
>> ' Make sure hidden text is not looked at
>> ActiveDocument.Range.TextRetrievalMode.IncludeHiddenText = False
>>
>> ' Do your Replace here
> Also an important distinction is that Selection.Find does not seem to work
> with TextRetrievalMode.
Selection.Find does work as long the Show/Hide Button isn't hiding the text
like:
ActiveWindow.ActivePane.View.ShowAll = False
Before doing a selection find. That doesn't seem to matter when using a
range find.
> You must use Range.Find. Something like this macro will delete everything
> except hidden text.:
>
> Sub Macro13()
> Dim aRange As Range
>
> ActiveDocument.Range.TextRetrievalMode.IncludeHiddenText = False
> Set aRange = ActiveDocument.Content
>
> With aRange.Find
> .Font.hidden = False
> .Text = ""
> .Replacement.Text = ""
> .Execute Replace:=wdReplaceAll
> End With
>
> End Sub
>>
>> ' Reset to user's option, saved above
>> Options.DeletedTextMark = DeletedTextOption
>>
>> --
>> Enjoy,
>> Tony
>>
>> "John Sharp" <John Sharp@discussions.microsoft.com> wrote in message
>> news:1E62BE27-BE4C-44E6-90DC-508466E7AE83@microsoft.com...
>>> I'm trying to write a macro that finds & replaces several things all in
>> one
>>> batch. Track changes needs to be on.
>>>
>>> The problem is that the "finds" also see and act on deleted text. How can
>> I
>>> run a find and replace that ignores the deleted text? I know this was a
>>> problem in Word 97 because I found a KB article on it. Surely they fixed
>> it
>>> by now?
>>>
>>> I have tried limiting finds for black text or font style normal...that
>>> doesn't work.
>>
>>
--
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID