Print Settings VS Macro Print Settings

Status
Not open for further replies.

Flavien

Board Regular
Joined
Jan 8, 2023
Messages
77
Office Version
  1. 365
Platform
  1. Windows
Hello,

Below is a code that allows me to open one by one the workbooks contained in a folder and to print the sheets mentioned on a master workbook.

I'm annoyed because the default settings of the workbook get the upper hand on the macro settings. thus, the files are printed in black and white if the file was saved in black and white and in color if it was saved in color.

Rich (BB code):
Sub impression_GCU()

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(ThisWorkbook.Worksheets("IMPRESSION").Range("B5").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 ActiveWorkbook.Worksheets("PCP A3H")
            .PageSetup.BlackAndWhite = False
            .PageSetup.Orientation = xlLandscape
            .PageSetup.PaperSize = xlPaperA3
            .PrintOut From:=1, To:=1, copies:=1
      
        End With
        
        'Imprimer la feuille Métrologie Saisie Manuscrite
        With ActiveWorkbook.Worksheets("Métrologie Saisie Manuscrite")
        .PageSetup.BlackAndWhite = False
        .PageSetup.Orientation = xlLandscape
        .PageSetup.PaperSize = xlPaperA4
        .PrintOut copies:=5

        End With


'   Fermer le classeur et passer au suivant

wb.Close savechanges = False


Next oFichier

Application.ScreenUpdating = True

End Sub
 

Attachments

  • Capture.JPG
    Capture.JPG
    31.2 KB · Views: 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Duplicate to: Printing: File settings override code

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread. If you do not receive a response, you can "bump" it by replying to it yourself (& add any additional information or clarification), though we advise you to wait 24 hours before doing so, and not to bump a thread more than once a day.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,723
Messages
6,174,117
Members
452,545
Latest member
boybenqn

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