We help IT Professionals succeed at work.

Print Range Macro

Hi,
I would like to use a macro to cycle through multiple tabs in a workbook and setup the print range.  I want  each tab to be a page and all contents to fit on one page in landscape on a standard 8.5 by 11 page.  

Thanks
Montrof
Comment
Watch Question

Michael VasilevskySolutions Architect
CERTIFIED EXPERT

Commented:
Try this code:

Sub MyMacro
    Dim ws As Worksheet
    
    For Each ws In ActiveWorkbook.Worksheets
        With ws.PageSetup
            .Orientation = xlLandscape
            .FitToPagesWide = 1
            .FitToPagesTall = 1
        End With
        
        On Error Resume Next
    Next ws
    
End Sub

Open in new window

Top Expert 2008

Commented:
Try this on your selected sheets

Sub Macro1()
'
' Macro1 Macro
'
Dim sht As Worksheet

Application.PrintCommunication = False

For Each sht In ActiveWindow.SelectedSheets
    
    With sht.PageSetup
        .Orientation = xlLandscape
        .PaperSize = xlPaperLetter
        .FitToPagesWide = 1
        .FitToPagesTall = 1
    End With
    
Next sht

Application.PrintCommunication = True
End Sub

Open in new window


Thomas

Author

Commented:
Thank you for the Macros but neither work, Each tab is still showing mutiple pages. I do not know if it maters but there are graphs on the tabs.
Solutions Architect
CERTIFIED EXPERT
Commented:
Please try this modification:

    Dim ws As Worksheet
    
    For Each ws In ActiveWorkbook.Worksheets
        With ws.PageSetup
            .Orientation = xlLandscape
            .Zoom = False
            .FitToPagesWide = 1
            .FitToPagesTall = 1
        End With
        
        On Error Resume Next
    Next ws

Open in new window

Author

Commented:
Perfect thank you so much for the help

Explore More ContentExplore courses, solutions, and other research materials related to this topic.