Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bunch of MS Word 2010 documents and I need to convert them from Letter page size to A4. Is there a simple way to do that? Possibly some PowerShell script combined with some MS Word API?

share|improve this question

Here is some VBA you can add as a macro to change all the Word documents in a given folder.

WARNING: Make a backup copy of your files prior to running this code.

Open a new Word document, paste this code into the VBA window (Alt+F11). Make necessary changes to the path, then close the window.

Sub ChangePaperSize()
Dim myFile As String
Dim myPath As String
Dim myDoc As Document

'Change to the path where your documents are located.
'This code changes ALL documents in the folder.
'You may want to move only the documents you want changed to seperate folder.
myPath = "C:\temp\"

'Closes open documents before beginning
Documents.Close SaveChanges:=wdPromptToSaveChanges

'Set the path with file name for change
myFile = Dir$(myPath & "*.docx")

    Do While myFile <> ""

    'Open the document and make chages
    Set myDoc = Documents.Open(myPath & myFile)
    myDoc.PageSetup.PaperSize = wdPaperA4

    'Close and saving changes
    myDoc.Close SaveChanges:=wdSaveChanges

    'Next file
    myFile = Dir$()
    msgbox "Process complete!"    
End Sub

Open the Macro window (Alt+F8) and choose ChangePaperSize, then click run. The current open document will close and other documents will open and close as it makes the changes to each document in the folder.

share|improve this answer
Excellent, thanks, that gave me enough clues to write the same thing in PowerShell (which I find easier to use). Will post the code as separate answer. – Borek Sep 27 '12 at 19:02
Great. Glad to help. – CharlieRB Sep 27 '12 at 19:13

PowerShell version based on CharlieRB's answer:

    [string] $Path

$docFiles = (Get-ChildItem $Path -Include *.docx,*.doc -Recurse)

$word = New-Object -com Word.Application

foreach ($docFile in $docFiles) {

    $doc = $word.Documents.Open($docFile.FullName)
    $doc.PageSetup.PaperSize = [Microsoft.Office.Interop.Word.WdPaperSize]::wdPaperA4



share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .