Change the Normal Style

Viewed 29

I would like to programmatically alter the main built-in fonts in a Word document. At present, I've been updating them from another template, but I see a risk if the other template is not present when deployed, so I'd like to specify them in code alone.

     ActiveDocument.Styles.Add Name:="Normal", Type:=wdStyleTypeParagraph
     ActiveDocument.Styles("Normal").AutomaticallyUpdate = True
     With ActiveDocument.Styles("Normal").font
         .Name = "3Dumb"                     ' random font to see it works
         .Size = 10
         .Bold = True
         .Italic = True
         .Underline = wdUnderlineNone
         .UnderlineColor = wdColorAutomatic       'etc...

Obviously, VBA complains because that is a built-in style. However, there doesn't seem to be a Styles.Edit Method.

Does anyone know of a solution to redefine built in styles in Word?

MTIA

Fr. S

1 Answers

You don't need to add the style but reference it:

Sub alterStyles()

Dim sty As Style
Set sty = ActiveDocument.Styles(wdStyleNormal)

With sty.Font
    .Name = "3Dumb"
End With

         
End Sub

Use the wdBuiltInStyle-constants to access the styles - as their names are not the same over different languages.

But usually it is the use case of templates to provide the correct styles ... not a macro that changes them...

Related