Is it possible to create a Word 2003 Macro to change the font style of certain segments of a document?
For example, say I have a document that has a large portion of text as bold italic and 12 point font. I'd like to replace all text with these characteristics with underlined 14 point font.
I've already done some searches on Google, StackOverflow and Microsoft's website but I haven't been able to find anything that discusses if this is even possible.
Any help?
Yeah, you'll want to use the .Find object and it's child .Replacement content. You can do this on a Selection (limited run), a Range (paragraphs, stories, etc.) or the whole document. The sample below is for the whole document (ActiveDocument.Content).
Sub FindReplaceStyle()
With ActiveDocument.Content.Find
.ClearFormatting
With .Font
.Bold = True
.Size = 14
.Italic = True
End With
.Format = True
With .Replacement
.ClearFormatting
With .Font
.Bold = False
.Italic = False
.Underline = wdUnderlineSingle
.Size = 12
End With
End With
.Execute Forward:=True, Replace:=wdReplaceAll, _
FindText:="", ReplaceWith:=""
End With
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With