VBA打印已保存的多个PDF,但每3秒打印一个?

好,所以我每天打印大约200多个pdf。 我知道我可以控制A并拖动他们的打印机,但每次我这样做,它打印3 5 PDF的。 有没有办法我可以写一个macros,告诉它打印每个pdf,并等待3或5秒,打印下一个?

到目前为止,我有这样的:

选项显式 

声明函数apiShellExecute库“shell32.dll”别名“ShellExecuteA”(_ 
 ByVal hwnd As Long,_ 
 ByVal lpOperation As String,_ 
 ByVal lpFile As String,_ 
 ByVal lpParameters As String,_ 
 ByVal lpDirectory作为string,_ 
 ByVal nShowCmd只要)_ 
只要 

 Public Sub PrintFile(ByVal strPathAndFilename As String) 

    调用apiShellExecute(Application.hwnd,“打印”,strPathAndFilename,vbNullString,vbNullString,0) 

结束小组 

子testing() 

     PrintFile(“C:\ Users \ gutierrezs \ downloads”) 

结束小组 

它不为我工作,因为我认为上述只是为了search文件名和打印一个。

您可能需要做的是创build包含您要打印的.pdf文件夹中的每个文件的列表,然后打印每个文件。

如何制作所有PDF的列表

如果必须,可以使用Wait方法等待3秒钟

这里是一个我修改为的vbs脚本:

executeGlobal CreateObject("Scripting.FileSystemObject").openTextFile(".\printPdfSrcFiles.vbs").readAll() 'Wscript.Quit() Dim pdfKey, printCmd, printJob, strMsg, pdfNo, objShell ' Read PDF print command from the registry Set objShell = CreateObject( "WScript.Shell" ) pdfKey = objShell.RegRead( "HKCR\.pdf\" ) printCmd = objShell.RegRead( "HKCR\" & pdfKey & "\shell\print\command\" ) If InStr( printCmd, "{" ) Then MsgBox ("Adobe Reader is not your edfault pdf reader") Set objArgs = WScript.Arguments For pdfNo = 1 to pdfFiles.Count printJob = Replace( printCmd, "%1", pdfFiles(pdfNo)) WScript.Sleep 1000 objShell.Run(printJob) Next ' Done WScript.Quit(0) 

printPdfSrcFiles.vbs包含:

 dim pdfFiles dim i set pdfFiles = CreateObject("Scripting.Dictionary") i = 1 call pdfFiles.Add(i, "yourFirstPDFFilePath.pdf") : i = i + 1 call pdfFiles.Add(i, "yourSecondPDFFilePath.pdf") : i = i + 1 etc... 

对你来说至关重要的是WScript.Sleep 1000在打印另一个文件之前等待一秒钟,当然你可以从另一个来源例如Excel工作表检索你的pdf列表。