VBA for printing all the pdf files inside a folder.

hrithvik

New Member
Joined
May 26, 2019
Messages
7
Sub Bulk_Print_From_Folder()

Dim k As Variant
Dim n As Variant
Dim oFile As Object
Dim oFiles As Object
Dim oFolder As Object
Dim Path As Variant
Dim vItem As Object

Path
= "C:\Testing Folder"

With CreateObject("Shell.Application")
Set oFolder = .Namespace(Path)
If oFolder Is Nothing Then
MsgBox
"The Folder :" & vbLf & """" & Path & """ was Not Found.", vbCritical Exit Sub
End If
End With

Set oFiles = oFolder.Items
oFiles
.Filter 64, "*.pdf"

For n = 0 To oFiles.Count - 1
Set oFile = oFiles.Item(n)
For k = 0 To oFile.Verbs.Count - 1
Set vItem = oFile.Verbs.Item(k)
If Not vItem Is Nothing Then
If Replace(vItem, "&", "") = "Print" Then vItem.DoIt
End If
Next k
Next n

End Sub


 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
do you have a problem with the macro?
It sends you an error, which error, in which line?


Here another way:

Code:
Sub PrintPdfs()
    Dim wPath As String, wFile As Variant
    
    wPath = "C:\Testing Folder\"
    wFile = Dir(wPath & "*.pdf")
    
    Do While wFile <> ""
        ruta = "C:\Program Files\Adobe\Reader 11.0\Reader\"
        Shell ruta & "AcroRd32.exe /n /t " & wPath & wFile
        DoEvents
        Application.Wait Now + TimeValue("00:00:02")
        wFile = Dir()
    Loop
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top