在日常办公中,经常需要一次性打印多个Word文档。手动逐个打开并打印不仅耗时,还容易出错。本文将介绍几种实用的方法,帮助您高效完成批量打印任务。
Alt + F11 打开VBA编辑器。
Sub BatchPrintWordFiles()
Dim folderPath As String
Dim fileName As String
Dim doc As Document
folderPath = "C:\Your\Document\Folder\" ' 修改为你的文件夹路径
fileName = Dir(folderPath & "*.doc*")
Do While fileName <> ""
Set doc = Documents.Open(folderPath & fileName)
doc.PrintOut
doc.Close SaveChanges:=wdDoNotSaveChanges
fileName = Dir
Loop
MsgBox "批量打印完成!"
End Sub
运行宏后,Word会自动打开每个文档并发送打印任务。
如果你熟悉命令行,可以使用PowerShell实现无界面批量打印:
$folder = "C:\Your\Document\Folder"
$word = New-Object -ComObject Word.Application
$word.Visible = $false
Get-ChildItem -Path $folder -Filter *.doc* | ForEach-Object {
$doc = $word.Documents.Open($_.FullName)
$doc.PrintOut()
$doc.Close()
}
$word.Quit()
保存为 print.ps1 并以管理员权限运行(需允许脚本执行)。
部分专业软件支持批量打印功能,例如:
这些工具通常提供图形界面,操作更直观,适合非技术人员使用。