Hi all,
Here's what I need to be able to do:

Sample Text:
Mary had a little lamb, little lamb, little lamb; Mary had a little lamb
(forgot what comes after)

Now, assuming that all the 'lamb's are in Bold, I need to Find and Replace
all Bold words and tag them appropriately.

So, the answer would be:
Mary had a little <BOLD>lamb</BOLD>, little <BOLD>lamb</BOLD>, little
<BOLD>lamb</BOLD>; Mary had a little <BOLD>lamb</BOLD> (forgot what comes
after)

Now, if I find and Replace and use Bold Formatting, the original text is
taken text away, leaving me with this:
Mary had a little <BOLD></BOLD>, little <BOLD></BOLD>, little <BOLD></BOLD>;
Mary had a little <BOLD></BOLD> (forgot what comes after)

So, how do you think I should be able to code this? Please don't tell me to
go through the text, word by word...

Thank you for your suggestions and for reading.
Vince

Re: Find & Replace Question by Vince

Vince
Mon Sep 27 03:43:51 CDT 2004

Never mind!!! I figured it out!! It goes:

Find : Formatting BOLD
Replace with: This thingo below
<BOLD>^&</BOLD>

and why didn't I think of this earlier!!

Vince
"Vince" <sdsad@fsd.com> wrote in message
news:OWE$PuGpEHA.2304@TK2MSFTNGP14.phx.gbl...
> Hi all,
> Here's what I need to be able to do:
>
> Sample Text:
> Mary had a little lamb, little lamb, little lamb; Mary had a little lamb
> (forgot what comes after)
>
> Now, assuming that all the 'lamb's are in Bold, I need to Find and Replace
> all Bold words and tag them appropriately.
>
> So, the answer would be:
> Mary had a little <BOLD>lamb</BOLD>, little <BOLD>lamb</BOLD>, little
> <BOLD>lamb</BOLD>; Mary had a little <BOLD>lamb</BOLD> (forgot what comes
> after)
>
> Now, if I find and Replace and use Bold Formatting, the original text is
> taken text away, leaving me with this:
> Mary had a little <BOLD></BOLD>, little <BOLD></BOLD>, little
<BOLD></BOLD>;
> Mary had a little <BOLD></BOLD> (forgot what comes after)
>
> So, how do you think I should be able to code this? Please don't tell me
to
> go through the text, word by word...
>
> Thank you for your suggestions and for reading.
> Vince
>
>



Re: Find & Replace Question by Helmut

Helmut
Mon Sep 27 03:53:22 CDT 2004

Hi Vince,
like this:
Sub Resetsearch()
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
End With
End Sub
Sub Test321()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
Resetsearch
With rDcm.Find
.Text = ""
.Font.Bold = True
.MatchWholeWord = True
.Replacement.Text = "<BOLD>lamb</BOLD>"
.Replacement.Font.Bold = False
.Execute Replace:=wdReplaceAll
End With
Resetsearch
End Sub
---
Making the replacement text not bold is
advisable. Otherwise you may end up with
<BOLD><BOLD>lamb</BOLD></BOLD> etc.
for each run of the macro. Though
.MatchWholeWord = True takes care of that
problem here. But would not take care,
if you wanted to replace something like
" in this moment ", possibly preceeded and
followed by bold spaces.
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000



Re: Find & Replace Question by Helmut

Helmut
Mon Sep 27 03:58:12 CDT 2004

Sorry,
forget it. Not my day.
Though there is some truth in some details.
HW

Re: Find & Replace Question by Helmut

Helmut
Mon Sep 27 04:05:52 CDT 2004

Hi,
improved version, though replacing all
bold text by "lamb" was obviously not meant
seriously.
Typing too fast. I'm ashamed.
Sub Test321()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
Resetsearch
With rDcm.Find
.Text = ""
.Font.Bold = True
.MatchWholeWord = True
.MatchWildcards = True
.Replacement.Text = "<BOLD>^&</BOLD>"
.Replacement.Font.Bold = False
.Execute Replace:=wdReplaceAll
End With
Resetsearch
End Sub
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000


Re: Find & Replace Question by Vince

Vince
Mon Sep 27 04:26:19 CDT 2004

Thanks Helmut! Trust me, I have had many & many of those kind of days!
vince
"Helmut Weber" <anonymous@discussions.microsoft.com> wrote in message
news:293e01c4a471$3044a000$a301280a@phx.gbl...
> Hi,
> improved version, though replacing all
> bold text by "lamb" was obviously not meant
> seriously.
> Typing too fast. I'm ashamed.
> Sub Test321()
> Dim rDcm As Range
> Set rDcm = ActiveDocument.Range
> Resetsearch
> With rDcm.Find
> .Text = ""
> .Font.Bold = True
> .MatchWholeWord = True
> .MatchWildcards = True
> .Replacement.Text = "<BOLD>^&</BOLD>"
> .Replacement.Font.Bold = False
> .Execute Replace:=wdReplaceAll
> End With
> Resetsearch
> End Sub
> ---
> Greetings from Bavaria, Germany
> Helmut Weber, MVP
> "red.sys" & chr(64) & "t-online.de"
> Word 2002, Windows 2000
>