2
votes

I'm trying to figure out how to set the font style for an entire word document, exactly the way it's done by choosing a style preset in the menu:

Changing font style presets

Since I've already made a macro that converts the entire document word for word, what I'm trying to accomplish with this is changing all the preset tiles (Normal, No Spacing, Title, Heading 1, etc.) to match this existing preset, and not the old presets (with the old fonts).

Is this possible, and what object do I modify to accomplish this?

2

2 Answers

2
votes

Try this ...

Sub ChgFontInAllStyles()
Dim sty As Word.Style
For Each sty In ActiveDocument.Styles
    If sty.InUse And sty.Type = wdStyleTypeParagraph Then
        sty.Font.Name = "Arial"
    End If
Next
End Sub
1
votes

What you show in the screen shot is an Office Theme. This is not the same as a Word style, although some of the settings do "filter through" to the built-in styles and custom styles that base on these.

Themes is a complex topic if it's a question of defining a custom theme programmatically. If all you want to do is apply an existing theme, then:

Dim sThemePath as String
sThemePath = "C:\Program Files\Microsoft Office\Document Themes 14\Equity.thmx"
ActiveDocument.ApplyDocumentTheme sThemePath

It's necessary to specify the entire path. In the sample code this is the default path for the built-in Office themes for Office 2010.