SubPrintPDf(fnAs String)Dim pdfEXE As String Dim q As String pdfEXE=ExePath(fn)If pdfEXE=""Then MsgBox"没有找到pdf相关的EXE程序.",vbCritical,"Macro Ending"Exit Sub End If q="""Shell q&pdfEXE&q&" /s/o /h /t "&q&fn&q,vbHide End Sub FunctionExePath(lpFile As String)As Strin...
sub openandprintpdf() dim pdfpath as string pdfpath = "c:\your\pdf\file.pdf" '修改为实际的pdf路径 shell "c:\program files (x86)\adobe\acrobat reader dc\reader\acrord32.exe /t " & pdfpath & " ""your_printer_name""" end sub ``` 在代码中,通过shell命令调用pdf阅读器的可执行文件,...
acrobatPath="C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe"' 打印每个选中的PDF文件 For i=1To.SelectedItems.Count strFilePath=.SelectedItems(i)' 构建打印命令 printCommand="""&acrobatPath&""" /t """&strFilePath&"""' 使用Shell函数运行打印命令 Shell printCommand,vbHide ' 等待打印完...
代码如下:DeclareFunction FindExecutable Lib “shell32.dll” Alias “FindExecutableA” _(ByVal lpFileAs String, ByVal lpDirectory As String, ByVal lpResult As String) As LongSub Test_PrintPDF()Dim strFileName As StringstrFileName = “D:\test.pdf”PrintPDf strFileNameEnd SubSub ...
DeclareFunction FindExecutable Lib "shell32.dll" Alias "FindExecutableA" _(ByVal lpFileAs String, ByVal lpDirectory As String, ByVal lpResult As String) As LongSub Test_PrintPDF()Dim strFileName As StringstrFileName = "D:\test.pdf"PrintPDf s...
DeclareFunction FindExecutable Lib “shell32.dll” Alias “FindExecutableA” _ (ByVal lpFileAs String, ByVal lpDirectory As String, ByVal lpResult As String) As Long Sub Test_PrintPDF() Dim strFileName As String strFileName = “D:\test.pdf” PrintPDf strFileName End Sub Sub PrintPDf(f...
.Filters.Add "All pdf files", "*.pdf", 1 'PDFfile .AllowMultiSelect = True 'MultiSelect If .Show Then mypath = .SelectedItems(1) Else Exit Sub For i = 1 To .SelectedItems.Count s = .SelectedItems(i) ShellExecute Application.hwnd, "print", s, "", "", SW_HIDE Next End With...
PrintPDf strFileName End Sub Sub PrintPDf(fnAs String) Dim pdfEXE As String Dim q As String pdfEXE = ExePath(fn) If pdfEXE = “” Then MsgBox “没有找到pdf相关的EXE程序.”,vbCritical, “Macro Ending” Exit Sub End If q = “””” ...
在vba中打印pdf文件可按以下步骤操作。首先,需要引用adobe acrobat的库(若未安装adobe acrobat则无法进行)。通过vba代码创建一个acrobat对象,例如“dim acroapp as acrobat.acroapp”并进行初始化。然后打开pdf文件,像“set pdfdoc = acroapp.open(pdffilepath)”。接着获取打印对象“set printjob = pdfdoc.print...
有些PDF阅读器支持通过命令行参数直接打印PDF文件。例如,Adobe Acrobat Reader支持使用/t参数来打印。 vba Sub PrintPDFWithCommand() Dim pdfPath As String pdfPath = "C:\path\to\your\file.pdf" ' 请将这里的路径替换为你的PDF文件路径 ' 确保路径和参数用双引号括起来 Shell """ & "C:\Program...