如何将 MS Word 文件从 Letter 页面大小批量转换为 A4?

Bor*_*ard 1 api microsoft-word

我有一堆 MS Word 2010 文档,我需要将它们从 Letter 页面大小转换为 A4。有没有一种简单的方法可以做到这一点?可能是一些 PowerShell 脚本与一些 MS Word API 相结合?

Cha*_*eRB 5

这是一些 VBA,您可以将其添加为宏以更改给定文件夹中的所有 Word 文档。

警告:在运行此代码之前制作文件的备份副本。

打开一个新的 Word 文档,将此代码粘贴到 VBA 窗口 ( Alt+ F11) 中。对路径进行必要的更改,然后关闭窗口。

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$()
    Loop
    msgbox "Process complete!"    
End Sub
Run Code Online (Sandbox Code Playgroud)

打开宏窗口 ( Alt+ F8) 并选择ChangePaperSize,然后单击运行。当它对文件夹中的每个文档进行更改时,当前打开的文档将关闭,而其他文档将打开和关闭。