Printing error. Nothing is printed

Flavien

Board Regular
Joined
Jan 8, 2023
Messages
61
Office Version
  1. 365
Platform
  1. Windows
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?

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
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
do you get an error message at the printer?
Are the metric sizes (A3, A4) recognized by the printer?

Try the code like this:
VBA Code:
        ' Print sheet 1
        With ActiveWorkbook.Worksheets("Feuil1")
            Application.PrintCommunication = False
            .PageSetup.BlackAndWhite = False
            .PageSetup.Orientation = xlLandscape
            .PageSetup.PaperSize = xlPaperA3
            Application.PrintCommunication = True
            .PrintOut From:=1, To:=1, copies:=1
        End With
and then the same for sheet 2
 
Upvote 0
do you get an error message at the printer?
Are the metric sizes (A3, A4) recognized by the printer?

Try the code like this:
VBA Code:
        ' Print sheet 1
        With ActiveWorkbook.Worksheets("Feuil1")
            Application.PrintCommunication = False
            .PageSetup.BlackAndWhite = False
            .PageSetup.Orientation = xlLandscape
            .PageSetup.PaperSize = xlPaperA3
            Application.PrintCommunication = True
            .PrintOut From:=1, To:=1, copies:=1
        End With
and then the same for sheet 2

Hello Bobsan42,

Thank you for your help.
1. No error message at the printer (only on the computer
2. Yes the both sizes (A3 & A4) are available on the printer.
3. Unfortunately the code doesn't work.

=> Before posting my question, I did some program tests. Is it possible that one of my trials is causing this problem?
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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