在VBA中调用Adobe Acrobat或Reader的命令行工具,实现PDF自动打印 (‾◡◝)

在VBA(Visual Basic for Applications)中自动打印PDF文件通常不直接支持,因为VBA本身是针对Microsoft Office应用程序(如Excel、Word和PowerPoint等)的编程语言,并不直接处理PDF文件。但是,你可以通过调用Adobe Acrobat或Reader的命令行工具间接实现自动打印PDF文件的功能。

一、操作步骤

首先需要为你的电脑安装Adobe Acrobat或Reader,你可以使用它们的命令行工具(如AcroRd32.exe)来打印PDF文件。其次需要Acrobat或Reader的安装路径(可能因版本和安装位置而异)。最后编写VBA代码调用命令行。

vbnet 复制代码
Sub PrintPDF()
    '自动打印单个PDF文件
    
    Const Path_Pdf As String = "C:\Users\Desktop\test.pdf"
    Const Adobe_exe As String = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"
    Const Printer_Name As String = "Print Driver"
    Dim shellCommand As String
    
    shellCommand = Adobe_exe & " /p /h " & Path_Pdf
    Shell shellCommand, vbHide
    
End Sub


'选择打印机 /t
'shellCommand = Adobe_exe & " /p /h /t "& Printer_Name & Path_Pdf
vbnet 复制代码
Sub BatchPrintPDF()
    '批量打印PDF文件
    
    Const Path_Pdf As String = "C:\Users\Desktop\test"
    Const Adobe_exe As String = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"
    Dim shellCommand As String

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set Folder = fso.GetFolder(Path_Pdf)

    For Each file In Folder.Files
       shellCommand = Adobe_exe & " /p /h " & file
       Shell shellCommand, vbHide
    Next file
    
End Sub
相关推荐
AI刀刀6 分钟前
Kimi 保存 pdf 显示该页的尺寸超出范围令人困扰,AI 导出鸭一键修复参数,导出 PDF 更顺畅
人工智能·pdf·ai导出鸭
2601_9611940212 小时前
2026四六级翻译预测12篇|四级六级汉译英范文PDF
pdf
2601_9611940212 小时前
2026四六级翻译预测|四级六级汉译英热点+范文PDF
pdf
绘梨衣54713 小时前
豆包Seed PDF解析企业落地方法论
大数据·python·pdf
庖丁AI14 小时前
PDF解析工具怎么选?OCR、表格提取和结构化输出有什么区别
人工智能·pdf·ocr
2601_961194021 天前
27考研刘晓艳单词pdf
linux·sql·ubuntu·华为·pdf·.net
AI刀刀1 天前
智谱清言保存 pdf 显示该页的尺寸超出范围,AI 导出鸭智能适配页面尺寸稳定导出 PDF
人工智能·pdf·ai导出鸭
GIS从业者1 天前
免费的PDF工具PDF24工具箱
pdf
2601_961194021 天前
专升本财务管理重点知识整理|2026财务管理真题计算题PDF电子版
pdf
俊哥工具1 天前
电脑怎么玩手机APP?超简单新手教程
pdf·电脑·word·excel·音视频