Find/replace data in quote marks

T

Tracey, London

I often have to format normal text that is in quote marks to bold & Italic.
The text is usually in brackets, for example (the "client"). I need the word
client to be in bold & italics and everything else to be in normal font.
Sometimes I will have over 300 different words in a document that need to be
formatted this way. Is there any easy way of doing a find and replace for
this? I have looked for hours and can't see a way.
 
G

Greg Maxey

Tracey,

This should get you close:

Sub ScratchMacro()
'Bold/Italicize text exclusive of the quotes marks
Dim oRng As Range
Dim oRng2 As Range
Set oRng = ActiveDocument.Content
With oRng.Find
.ClearFormatting
.Text = "\(*\)"

.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
Do While .Execute
Set oRng2 = oRng.Duplicate
With oRng2.Find
.Text = """<*>"""
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Execute
If .Found Then
oRng2.MoveEnd unit:=wdCharacter, Count:=-1
oRng2.MoveStart unit:=wdCharacter, Count:=1
oRng2.Font.Bold = True
oRng2.Font.Italic = True
oRng2.Collapse wdCollapseEnd
End If
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