Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Find and Replace words within "parentheses" | Microsoft Word Help | |||
How do i find and replace words in parenthesis? | Microsoft Word Help | |||
Find & Replace change to Uppercase two words | Microsoft Word Help | |||
Trying to replace words with fields using Find/Replace | Microsoft Word Help | |||
Find/ Replace is auto-capping the words I want to replace with | Microsoft Word Help |