Bold formatting

S

Sajja

Hi,

I would like to format text to bold which comes in between two special
characters, say all the text between # and * as in below .

word document formatting # is easy if you know * macro coding.

Please provide me a code snippet for this as I'm new to VBA code.

Thanks in advance.
Sajja
 
G

Greg Maxey

Something like this:

Sub FindAndBoldTextBetweenSpecCharacters()

Dim oRng As Range
Set oRng = ActiveDocument.Content

With oRng.Find
.ClearFormatting
.Text = "#<*>[/*]"
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
Do While .Execute
With oRng
.Font.Bold = True
.Collapse wdCollapseEnd
End With
Loop
End With
End Sub
 
S

Sajja

Thanks a lot Greg, it worked.

Greg Maxey said:
Something like this:

Sub FindAndBoldTextBetweenSpecCharacters()

Dim oRng As Range
Set oRng = ActiveDocument.Content

With oRng.Find
.ClearFormatting
.Text = "#<*>[/*]"
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
Do While .Execute
With oRng
.Font.Bold = True
.Collapse wdCollapseEnd
End With
Loop
End With
End Sub



--
Greg Maxey/Word MVP
A Peer in Peer to Peer Support
Hi,

I would like to format text to bold which comes in between two special
characters, say all the text between # and * as in below .

word document formatting # is easy if you know * macro coding.

Please provide me a code snippet for this as I'm new to VBA code.

Thanks in advance.
Sajja
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top