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 / December 2006

Tip: Looking for answers? Try searching our database.

Find and Replace doesnt work

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jack - 23 Dec 2006 01:04 GMT
If I use the find and replace command within Word to replace text including
text within a shape object) everything works.
But when I place the code in a vba module it doesnt find the text in any
shape objects.
My code is
   ActiveDocument.Content.Select
   With Selection.Find
       .ClearFormatting
       .Replacement.ClearFormatting
       .Text = "Year"
       .Replacement.Text = "2007"
       .Forward = True
       .Wrap = wdFindAsk 'wdFindContinue
       .Format = False
       .MatchCase = False
       .MatchWholeWord = False
       .MatchWildcards = False
       .MatchSoundsLike = False
       .MatchAllWordForms = False
   End With
   Selection.Find.Execute Replace:=wdReplaceAll

Any suggestions would be appreciated
jack
Doug Robbins - Word MVP - 23 Dec 2006 07:27 GMT
See the article "Using a macro to replace text where ever it appears in a
document including Headers, Footers, Textboxes, etc." at:

http://www.word.mvps.org/FAQs/MacrosVBA/FindReplaceAllWithVBA.htm

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> If I use the find and replace command within Word to replace text
> including text within a shape object) everything works.
[quoted text clipped - 20 lines]
> Any suggestions would be appreciated
> jack
Jack - 23 Dec 2006 18:52 GMT
Doug,,
Thank you very much.  That is exactly what I was looking for.  I had
actually been to that site searching but never came up with that article.
Thanks again
Jack
> See the article "Using a macro to replace text where ever it appears in a
> document including Headers, Footers, Textboxes, etc." at:
[quoted text clipped - 25 lines]
>> Any suggestions would be appreciated
>> jack
 
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.