Change Default Paper Size in Word (VBA)

Introduction

This VBA sample shows how to Change the default paper size in Word such as Letter to A4, A4 to A5.

Scenarios

Many users asked this question about how to change the default paper size (Letter) to others (A1, A2...B1, B2...) automatically.

Script

Step1. Press Alt+F11 to open the VBE in Word.
Step2. Select the files (PaperSize.bas and UserForm1.frm) and drag them to the Project or via File >> Import File... (Ctrl+M).
Step3. Go back to the document.
Step4. Press the Run button via Alt+F8.
Step5. Select "main" in the names list, and then click the Run button. We will see a window. Then select the paper size you want, click “submit” button.
 
Note 1. Please make sure that macros are enabled in Word.
For Word 2010:
File >> Options >> Trust Center >> Trust Center Settings >> Macro Settings >> Enable all macros >> OK >> OK >> Restart Word
Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.
 

VB Script
Edit|Remove
PublicFunction ChangeSize(PaperSize) 
OnErrorResumeNextDim envUSER, objshell 
Set objshell = CreateObject("wscript.shell"'Get the current username 
envUSER = objshell.expandEnvironmentStrings("%username%") 
  
Set Doc = Application.Documents.Open("C:\Users\" & envUSER & "\AppData\Roaming\Microsoft\Templates\Normal.dotm") 
'Set the specified number as the default paper sizeWith Application.Selection.PageSetup 
    .PaperSize = PaperSize 
    .SetAsTemplateDefault 
EndWith 
Doc.Save 
Doc.Close 
If Err.Number <> 0Then 
    MsgBox Err.Description, , "Configuration Warning"Else 
    MsgBox "Configure the default paper size successfully."EndIfEndFunction
Prerequisite

Office 2010 or Higher version