Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
El Capitán de las Albondigas El Capitán de las Albondigas is offline
external usenet poster
 
Posts: 4
Default Find and Replace all words that have a certain value in them, not just the value itself.

I want to be able to do a find/replace on all words that have "moogoo"
as part of the word. For example, if it finds "Franklinmoogoo" I want
it to replace the entire word with nothing. Currently I can only
replace moogoo with nothing, leaving me with Franklin, which I don't
want. I've tried using the wild card and finding "*moogoo" but for
some reason that finds the entire string of characters, including
spaces, before "moogoo." So, if my sentence said, "Hi my name is
Franklinmoogoo." It would highlight the entire sentence to replace.
I just want Word to highlight Franklinmoogoo and replace that. Any
ideas?

Gracias,
Sean

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey Greg Maxey is offline
external usenet poster
 
Posts: 264
Default Find and Replace all words that have a certain value in them, not just the value itself.

It is probably possible with Find and Replace and I can almost get
there except for a few cases. Klaue Linke or Graham Mayor may be by
to school us both. In the meantime, I believe you could do it like
this using a macro:

Sub Scratchmacro()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "moogoo" 'find the text string
While .Execute
'with found string, move the range forward while any alphabetical
character is encountered.
oRng.MoveEndWhile
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW XYZ"
'with the found string, move the range backwards while any
alphabetical character is encountered.
'500 is just an arbitrary value large enough for probably all
cases
oRng.MoveStartWhile
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW XYZ", -500
'Delete the range
oRng.Delete
Wend
End With
End Sub



On Sep 29, 8:42 pm, El Capitán de las Albondigas
wrote:
I want to be able to do a find/replace on all words that have "moogoo"
as part of the word. For example, if it finds "Franklinmoogoo" I want
it to replace the entire word with nothing. Currently I can only
replace moogoo with nothing, leaving me with Franklin, which I don't
want. I've tried using the wild card and finding "*moogoo" but for
some reason that finds the entire string of characters, including
spaces, before "moogoo." So, if my sentence said, "Hi my name is
Franklinmoogoo." It would highlight the entire sentence to replace.
I just want Word to highlight Franklinmoogoo and replace that. Any
ideas?

Gracias,
Sean



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and Replace words within "parentheses" Stabitha Microsoft Word Help 3 November 1st 06 11:33 AM
How do i find and replace words in parenthesis? Bob in Arizona Microsoft Word Help 5 September 1st 06 06:31 AM
Find & Replace change to Uppercase two words AAA Microsoft Word Help 2 July 3rd 06 08:52 AM
Trying to replace words with fields using Find/Replace mbleyle Microsoft Word Help 2 March 29th 06 11:35 PM
Find/ Replace is auto-capping the words I want to replace with Graham Mayor Microsoft Word Help 8 January 27th 06 01:39 AM


All times are GMT +1. The time now is 07:01 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"