Rydberg1995
Rydberg1995

Reputation: 49

Set font style for entire word document - VBA

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?

Upvotes: 2

Views: 4950

Answers (2)

Rich Michaels
Rich Michaels

Reputation: 1713

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

Upvotes: 2

Cindy Meister
Cindy Meister

Reputation: 25693

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.

Upvotes: 2

Related Questions