Hi
I have range object, which will contain something like --
[You must] read the later sections starting ['What you might getâ?¦ '] to see
the important notes about these figures and the [assumptions] weâ??ve made.

I want all text within [] make bold and get rid of []s. If [] have special
meaning then I can change them with "//" in database. I have tried following
from another post (thanks to Helmut Weber) --

Sub test10()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
With rDcm.Find
.Text = "/*/"
.MatchWildcards = True
While .Execute
rDcm.Start = rDcm.Start + 1
rDcm.End = rDcm.End - 1
' for testing in single step mode only [F8]
rDcm.Select ' delete after testing
rDcm.Font.Bold = True
rDcm.Start = rDcm.End + 1
rDcm.End = ActiveDocument.Range.End
Wend
End With
End Sub

Above works with // but not with [], still I need to delete //s.

Could some one please help, need this sorting soon

Re: How can I make all text "[" and "]" and Bold? by Greg

Greg
Fri Feb 17 08:39:27 CST 2006

Suhki,

If I understand correctly, you want words/phrases inside brackets to be
bolded and the brackets removed.

If correct, try:

Sub test10()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
With rDcm.Find
.Text = "(\[)(*)(\])"
.MatchWildcards = True
.Replacement.Text = "\2"
.Replacement.Font.Bold = True
.Execute Replace:=wdReplaceAll
End With
End Sub


Re: How can I make all text "[" and "]" and Bold? by Sukhi

Sukhi
Fri Feb 17 09:09:27 CST 2006

Thanks Greg
That is exactly what I wanted to do
-- What does "\2" means
.Replacement.Text = "\2"


"Greg" wrote:

> Suhki,
>
> If I understand correctly, you want words/phrases inside brackets to be
> bolded and the brackets removed.
>
> If correct, try:
>
> Sub test10()
> Dim rDcm As Range
> Set rDcm = ActiveDocument.Range
> With rDcm.Find
> .Text = "(\[)(*)(\])"
> .MatchWildcards = True
> .Replacement.Text = "\2"
> .Replacement.Font.Bold = True
> .Execute Replace:=wdReplaceAll
> End With
> End Sub
>
>

Re: How can I make all text "[" and "]" and Bold? by Greg

Greg
Fri Feb 17 09:16:29 CST 2006

Sukhi,

The find pattern is divided into three group using the parens ( ). The
first group is the opening bracket, the second group is your word or
phrase, and the third group is the closing bracket

You want to keep the the second group. You specify that using "\2"

See: http://www.gmayor.com/replace_using_wildcards.htm


Re: How can I make all text "[" and "]" and Bold? by Graham

Graham
Fri Feb 17 09:19:21 CST 2006

Actually you only need the middle set of brackets then replace with \1 ;)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Greg wrote:
> Sukhi,
>
> The find pattern is divided into three group using the parens ( ).
> The first group is the opening bracket, the second group is your word
> or phrase, and the third group is the closing bracket
>
> You want to keep the the second group. You specify that using "\2"
>
> See: http://www.gmayor.com/replace_using_wildcards.htm



Re: How can I make all text "[" and "]" and Bold? by Greg

Greg
Fri Feb 17 09:39:29 CST 2006

You mean the middle set of parens "(*)" i.e., "\[(*)\]"
and replace with "\1"

Agreed ;-)