Hello!
I would like to print all the workbooks contained in a folder.
These workbooks are designed in the same way and only 2 sheets interest me.
Each sheet has different printing settings.
The macro seems to work because the sheets appear in the print waitlist of windows, but there is an error.
In the end, nothing is printed.
Does anyone have an idea to explain to me what's wrong?
I would like to print all the workbooks contained in a folder.
These workbooks are designed in the same way and only 2 sheets interest me.
Each sheet has different printing settings.
The macro seems to work because the sheets appear in the print waitlist of windows, but there is an error.
In the end, nothing is printed.
Does anyone have an idea to explain to me what's wrong?
VBA Code:
Sub impression_GCU_4()
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-ABC\02-ABC" & "\")
For Each oFichier In oDossier.Files
' Ouvrir chaque classeur contenu dans le dossier
Set wb = Workbooks.Open(Filename:=oFichier)
' Set the pages to be printed and the print properties
' Print sheet 1
With ActiveWorkbook.Worksheets("Feuil1")
.PageSetup.BlackAndWhite = False
.PageSetup.Orientation = xlLandscape
.PageSetup.PaperSize = xlPaperA3
.PrintOut From:=1, To:=1, copies:=1
End With
' Print sheet 2
With ActiveWorkbook.Worksheets("Feuil2")
.PageSetup.BlackAndWhite = False
.PageSetup.Orientation = xlLandscape
.PageSetup.PaperSize = xlPaperA4
.PrintOut copies:=5
End With
' Close the activeworkook
wb.Close savechanges = False
Next oFichier
Application.ScreenUpdating = True
End Sub