Macro to format text between square brackets and text with in braces

J

jb

Hello,

I am a word macro neophyte at best.

What I would like is a macro that would:
bold, font size =14, font color = blue all text between square
brackets [ ] and put all text between braces, { } to font size 10,
italics, color=red. Any direction would be appreciated. Thank-you.

JB
 
G

Greg Maxey

Sub ScratchMacro()
Dim oRng As Range
Set oRng = ActiveDocument.Content
With oRng.Find
.ClearFormatting
.Text = "\[*\]"
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
Do While .Execute
With oRng
.MoveEnd unit:=wdCharacter, Count:=-1
.MoveStart unit:=wdCharacter, Count:=1
.Font.Color = wdColorBlue
.Font.Bold = True
.Font.Size = "14"
.Collapse wdCollapseEnd
End With
Loop
End With
Set oRng = ActiveDocument.Content
With oRng.Find
.ClearFormatting
.Text = "\{*\}"
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
Do While .Execute
With oRng
.MoveEnd unit:=wdCharacter, Count:=-1
.MoveStart unit:=wdCharacter, Count:=1
.Font.Color = wdColorRed
.Font.Italic = True
.Font.Size = "10"
.Collapse wdCollapseEnd
End With
Loop
End With
End Sub
 

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