Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
replacing text with open/closing text marks or brackets
Hi,
I have a list of text. If a text contains an @ I want to enclosed that text with . Example: replace with If a text contains a space, I want to enclosed that text with ". Example: John & Jane Smith - "John & Jane Smith" I looked at "Find|Replace" with wildcards but did not find the right trick. Please help. Thanks! -- Lets Roll -W |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
replacing text with open/closing text marks or brackets
If this is a list of texts one per paragraph then the following macro will
add the extra characters as required With Selection .WholeStory .ConvertToTable Separator:=wdSeparateByParagraphs, NumColumns:=1 .HomeKey Unit:=wdStory With .Find .ClearFormatting .Replacement.ClearFormatting .Text = "*\@*.*" .Replacement.Text = "^&" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True '.Execute .Execute replace:=wdReplaceAll .Text = "[a-zA-Z ]{2,}&[a-zA-Z ]{2,}" .Replacement.Text = """^&""" .Execute .Execute replace:=wdReplaceAll End With .Tables(1).Select .Rows.ConvertToText Separator:=wdSeparateByParagraphs End With http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org GottaRun wrote: Hi, I have a list of text. If a text contains an @ I want to enclosed that text with . Example: replace with If a text contains a space, I want to enclosed that text with ". Example: John & Jane Smith - "John & Jane Smith" I looked at "Find|Replace" with wildcards but did not find the right trick. Please help. Thanks! |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Find and Replace blocks of text within brackets | Microsoft Word Help | |||
word 2002- replacing highlighted text with new text | Microsoft Word Help | |||
Appearance of square brackets within text | New Users | |||
Replacing text, instead of replacing, text inserts alongside word | Microsoft Word Help | |||
replacing text | Microsoft Word Help |