Print ALL pages except for certain ones, and print double sided

vbanoob1234

New Member
Joined
Aug 8, 2016
Messages
26
Hi everyone,


My macro currently opens up all of the excel files in a certain path on my computer, and prints all visible sheets, single sided.
However, I want to fine tune my macro.
I have a bunch of hidden and very hidden sheet. I only want to print ALL of visible sheets, except for ones with the Worksheet Name "Master" "Deal" "Summary".
Also, I want to print all these sheets doubled side.

Sub PrintAll()


' Printsheets Macro




Dim wb As Workbook, ws As Worksheet
Dim sFil As String, sPath As String
Set wb = ActiveWorkbook
Set ws = ActiveSheet




Application.ScreenUpdating = False


'OPENS THE PATH
sPath = "P:\VBA" 'location of files, don't forget the "" at the end
sFil = Dir(sPath & "*.xls") 'change or add formats




Application.DisplayAlerts = False


'FIND ALL THE FILES TO PRINT
Do Until sFil = ""
Workbooks.Open sPath & sFil
Set wb = ActiveWorkbook


Application.ScreenUpdating = False


'PRINTS OUT ALL VISIBLE SHEETS
'ws.PrintOut
For Each ws In wb.Worksheets
If ws.Visible = xlSheetVisible Then ws.PrintOut
Next
wb.Close




sFil = Dir()
Loop
Application.DisplayAlerts = True


End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Double sided is referred to as Duplex Printing. https://msdn.microsoft.com/en-us/li...rinting.compatibility.vb6.printer.duplex.aspx

This code is UNTESTED but it will at least get you started. You'll have to add the double-sided printing feature to the code.


Code:
[COLOR=#333333]'Turn Alerts and Updating off
[/COLOR]
[COLOR=#333333]Application.DisplayAlerts = False     '<-- You should only need to place this at the top / beginning of your macro - it should not require repeating throughout the macro[/COLOR]
[COLOR=#333333]Application.ScreenUpdating = False[/COLOR]

[COLOR=#333333]'FIND ALL THE FILES TO PRINT
[/COLOR]
Dim ws As Worksheet
Dim WS_Count As Integer
Dim I As Integer

WS_Count = ActiveWorkbook.Worksheets.Count


' Begin the loop.
    For I = 1 To WS_Count
        With ThisWorkbook.Worksheets(I)
            If .Name <> "[COLOR=#333333]Master"[/COLOR] And .Name <>[COLOR=#333333]"Deal"[/COLOR] And .Name <> [COLOR=#333333]"Summary"[/COLOR] Then
                 [COLOR=#333333]If ws.Visible = xlSheetVisible Then[/COLOR]
                       [COLOR=#333333]ws.PrintOut
                 End If[/COLOR]
            End If
        End With
    Next I
[COLOR=#333333]wb.Close

[/COLOR][COLOR=#333333]Application.DisplayAlerts = True
[/COLOR][COLOR=#333333]Application.ScreenUpdating = True[/COLOR][COLOR=#333333]
[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,217,364
Messages
6,136,114
Members
449,993
Latest member
Sphere2215

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