Skip to main content

How to change the font and font size in all text boxes in Word document?

Author Siluvia Last modified

This article is talking about changing the font and font size in text boxes in current document or documents in a specified folder. Please try the VBA methods in the article.

Change the font and font size in text boxes in current document

Change the font and font size in text boxes of all documents in a folder


Change the font and font size in text boxes in current document

For the text boxes you will change the font and font size in current document, please apply the below VBA code to solve the problem.

1. Press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.

2. In the Microsoft Visual Basic for Applications window, click Insert > Module, and then copy the following code into the Module window.

VBA code: Change the font and font size in all text boxes in current document

Sub FormatTextsInTextBoxes()
'Updated by ExtendOffice 20181128
    Dim I As Long
    Dim xShape As Shape
    Dim xDoc As Document
    Set xDoc = ActiveDocument
    On Error Resume Next
    For Each xShape In xDoc.Shapes
        xShape.Select
        If xShape.GroupItems Is Nothing Then
            With xShape.TextFrame.TextRange.Font
                .Name = "Arial"
                .Size = 20
            End With
            GoTo LblExit
        End If
        For I = 1 To xShape.GroupItems.Count
            With xShape.GroupItems(I).TextFrame.TextRange.Font
                .Name = "Arial"
                .Size = 20
            End With
        Next
LblExit:
    Next
End Sub

Note: In the code, “Arial” and “20” is the specified font and font size in my case. You can change them based on your own needs.

3. Press the F5 key to run the code. Then all texts’ font and font size in the text boxes are changed to the specified font and font size. See screenshot:

Font and font size in the text boxes are changed to the specified ones


Change the font and font size in all text boxes of all documents in a folder

For changing text boxes’ font and font size in bulk in multiple Word documents, you need to apply the below VBA code.

1. Please collect all target documents that contain text boxes you will change the font and font size under the same folder.

2. In an opening Word document, press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.

3. In the Microsoft Visual Basic for Applications window, click Insert > Module, and then copy the following code into the Module window.

VBA code: Change the font and font size in text boxes of multiple documents

Sub FormatTextsInTextBoxesInMultiDoc()
'Updated by ExtendOffice 20181128
    Dim I As Long
    Dim xShape As Shape
    Dim xDlg As FileDialog
    Dim xFolder As Variant
    Dim xFileStr As String
    On Error Resume Next
    Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
    If xDlg.Show = -1 Then
        xFolder = xDlg.SelectedItems(1) + "\"
        xFileStr = Dir(xFolder & "*.doc", vbNormal)
        While xFileStr <> ""
            Documents.Open xFolder & xFileStr
            For Each xShape In ActiveDocument.Shapes
                xShape.Select
                If xShape.GroupItems Is Nothing Then
                    With xShape.TextFrame.TextRange.Font
                        .Name = "Arial"
                        .Size = 20
                    End With
                    GoTo LblExit
                End If
                For I = 1 To xShape.GroupItems.Count
                    With xShape.GroupItems(I).TextFrame.TextRange.Font
                        .Name = "Arial"
                        .Size = 20
                    End With
                Next
LblExit:
            Next
            ActiveDocument.Save
            ActiveDocument.Close
            xFileStr = Dir()
       Wend
    End If
End Sub

4. Press the F5 key to run the code. In the opening Browse window, select the folder (contains documents you will change font and font size in the text boxes) and click the OK button.

Browse window

Then all text boxes’ font and font size of documents in selected folder are changed to the specified font and font size.

Best Office Productivity Tools

Kutools for Word - Elevate Your Word Experience with Over 100 Remarkable Features!

🤖 Kutools AI Features: AI Assistant / Real-Time Assistant / Super Polish (Preserve Format) / Super Translate (Preserve Format) / AI Redaction / AI Proofread...

📘 Document Mastery: Split Pages / Merge Documents / Export Selection in Various Formats (PDF/TXT/DOC/HTML...) / Batch Convert to PDF...

Contents Editing: Batch Find and Replace across Multiple Files / Resize All Pictures / Transpose Table Rows and Columns / Convert Table to Text...

🧹 Effortless Clean: Sweap away Extra Spaces / Section Breaks / Text Boxes / Hyperlinks / For more removing tools, head to the Remove group...

Creative Inserts: Insert Thousand Separators / Check Boxes / Radio Buttons / QR Code / Barcode / Multiple Pictures / Discover more in the Insert group...

🔍 Precision Selections: Pinpoint Specific Pages / Tables / Shapes / Heading Paragraphs / Enhance navigation with more Select features...

Star Enhancements: Navigate to Any Location / Auto-Insert Repetitive Text / Toggle Between Document Windows / 11 Conversion Tools...

🌍 Supports 40+ Languages: Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Kutools and Kutools Plus tabs on the Word Ribbon
👉 Want to try these features? Download Kutools for Word now! 🚀
 

Best Office Productivity Tools

Kutools for Word - 100+ Tools for Word