How to change font family in multiple word files VBA

This VBA enables you to select a folder and change a font family name in all the word documents which are there in the folder. Let’s see the below VBA code for How to change font family in multiple word files VBA

VBA Code:

'Talentnett Solutions
Sub changeFontInAllDocsInFolder()
Dim file As Document
Dim folderPath As String
Dim filename As String
Dim sFldr As FileDialog

Application.Visible = False

    'Select Folder
    Set sFldr = Application.FileDialog(msoFileDialogFolderPicker)
    With sFldr
        If .Show = -1 Then 'Any folder is selected
            folderPath = .SelectedItems.Item(1) & "\"
        Else ' else dialog is cancelled
            MsgBox "You have cancelled the dialogue"
            folderPath = "None" ' when cancelled set blank as file path.
        End If
   End With

    filename = Dir(folderPath & "*.docx")

    Do Until filename = ""
        Set file = Documents.Open(folderPath & filename)
        file.Range.Font.Name = "Trebuchet MS" 'change font per your choice
        file.Close True
        filename = Dir()
Application.Visible = True

End Sub

#Step 1 – Open a Word File

#Step 2 – Press “ALT+F11”

#Step 3 – Click on Insert>>Module

#Step 4– Paste the above code in the VBA window and Press “Alt+Q”

VBA to change font family in multiple word document

#Step 5 – Save your word file as a macro-enabled file (Press “F12” >> change Save Type as “Word Macro-Enabled Document”)

#Step 6 – Press Ctrl+F9, it’ll insert brackets “{}”

#Step 7 – Paste below text in brackets

{MacroButton changeFontInAllDocsInFolder Change Font in Multiple Word File}


1st argument is a Macro Button (MacroButton)

2nd argument is a Macro Name (changeFontInAllDocsInFolder)

3rd argument is a Button name for Display (Change Font in Multiple Word File)

#Step 8 – Inside the bracket Press F9

#Step 9 – Double click on the text/button, it’ll run your macro

This article is all about How to change font family in multiple word files VBA

Read More:


Cool Tips and Tricks Directly Delivered in your Inbox. Subscribe to our Newsletter.

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

Talentnett will use the information you provide on this form to be in touch with you and to provide updates and marketing.