I need to print a series of pdf files.
If I use a loop to go through the files' names and use a shell.excecute to print them, each pdf file is opened, printed and closed. You can guess how it feels if I need to print let's say 20+ files.
A google search gave me the following function, where the author says vba will print the files without opening them. But no.
Still pdf opens (though shorter than shell.execute).
Is it possible to print a PDF file without first opening it?
Thanks for any kind of advice.
If I use a loop to go through the files' names and use a shell.excecute to print them, each pdf file is opened, printed and closed. You can guess how it feels if I need to print let's say 20+ files.
A google search gave me the following function, where the author says vba will print the files without opening them. But no.
Still pdf opens (though shorter than shell.execute).
SQL:
Public Sub PrintAnyDocument_WithoutOpening(ByVal strPathFile As String)
Dim TargetFolder
Dim FileName
Dim ObjShell As Object
Dim ObjFolder As Object
Dim ObjItem As Object
Dim ColItems As Object
If InStrRev(strPathFile, "\") <> 0 Then
TargetFolder = Left(strPathFile, InStrRev(strPathFile, "\"))
FileName = Right(strPathFile, Len(strPathFile) - Len(TargetFolder))
End If
Set ObjShell = CreateObject("Shell.Application")
Set ObjFolder = ObjShell.NameSpace(TargetFolder)
Set ColItems = ObjFolder.Items
For Each ObjItem In ColItems
If ObjItem.Name = FileName Then
ObjItem.InvokeVerbEx ("Print")
Exit For
End If
Next
Set ObjItem = Nothing
Set ColItems = Nothing
Set ObjFolder = Nothing
Set ObjShell = Nothing
End Sub
Is it possible to print a PDF file without first opening it?
Thanks for any kind of advice.