Hello everybody!
I frequently have to print batches of pdf files. The manual operation being tedious, I would like to automate this task.
I tried to adapt a code that I use to print excel files but, in this case, the pdf opens in excel format (total bug = A series of strange characters on each line of the workbook) and nothing happens.
Does anyone have an idea, please?
I frequently have to print batches of pdf files. The manual operation being tedious, I would like to automate this task.
I tried to adapt a code that I use to print excel files but, in this case, the pdf opens in excel format (total bug = A series of strange characters on each line of the workbook) and nothing happens.
Does anyone have an idea, please?
Rich (BB code):
Sub impression_PDF()
Dim oFSO As Object
Dim oDossier As Object
Dim oFichier As Object
Dim i As Integer
Dim wb As Workbook
Application.ScreenUpdating = False
Set oFSO = CreateObject("Scripting.FileSystemObject")
'Set oDossier = oFSO.GetFolder("P:\01-Qualité\K - Qualité Usinage\05 - CREATION PCP PREMIER NIVEAU\GCU A VALIDER\CA VERSO\FAST\ESSAI COPIE" & "\")
Set oDossier = oFSO.GetFolder(ThisWorkbook.Worksheets("IMPRESSION").Range("h5").Value & "\")
For Each oFichier In oDossier.Files
' Ouvrir chaque classeur contenu dans le dossier
Set wb = Workbooks.Open(Filename:=oFichier)
' Définir les pages à imprimer et les propriétés d'impression
'Imprimer la feuille PCP A3H
With oFichier
Application.PrintCommunication = False
.PageSetup.BlackAndWhite = False
.PageSetup.Orientation = xlLandscape
.PageSetup.PaperSize = xlPaperA3
Application.PrintCommunication = True
.PrintOut From:=1, To:=1, copies:=1
End With
' Fermer le classeur et passer au suivant
wb.Close savechanges = False
Next oFichier
Application.ScreenUpdating = True
End Sub