Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2006

Tip: Looking for answers? Try searching our database.

Word 2003 Find/Replace Doesn't Ignore Deleted Text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Sharp - 09 Sep 2006 17:12 GMT
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 - 09 Sep 2006 18:59 GMT
John,

> 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.

A little bit of semantics here ;-)
The text is still there and only "marked" for deletion by an overlay with
actual deletion pending until deletion change is accepted. That's why the
find function still sees it. If you select a piece of "marked" text and
bring up the font format dialog box, you'll see that the font format still
shows it as it was before being marked for deletion. It's like the dialog
box is not aware of the other "dimensional" marking overlay. The find dialog
box must not see it either.

>  How can I
> run a find and replace that ignores the deleted text?  I know this was a
[quoted text clipped - 3 lines]
> I have tried limiting finds for black text or font style normal...that
> doesn't work.

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Tony Jollans - 09 Sep 2006 20:37 GMT
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

   ' Reset to user's option, saved above
   Options.DeletedTextMark = DeletedTextOption

--
Enjoy,
Tony

> I'm trying to write a macro that finds & replaces several things all in one
> batch.  Track changes needs to be on.
[quoted text clipped - 6 lines]
> I have tried limiting finds for black text or font style normal...that
> doesn't work.
Russ - 09 Sep 2006 22:18 GMT
> To make F&R ignore deleted text you need to make it hidden, something like
> this ...
[quoted text clipped - 9 lines]
>
>     ' Do your Replace here
Also an important distinction is that Selection.Find does not seem to work
with TextRetrievalMode.
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
[quoted text clipped - 16 lines]
>> I have tried limiting finds for black text or font style normal...that
>> doesn't work.

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Russ - 09 Sep 2006 22:42 GMT
Oops,

>> To make F&R ignore deleted text you need to make it hidden, something like
>> this ...
[quoted text clipped - 11 lines]
> 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.:
[quoted text clipped - 34 lines]
>>> I have tried limiting finds for black text or font style normal...that
>>> doesn't work.

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.