+ Reply to Thread
Results 1 to 2 of 2

VBA Alternating between Portrait and Landscape to print

  1. #1
    Registered User
    Join Date
    03-20-2021
    Location
    Brisbane,Australia
    MS-Off Ver
    Microsoft Office 2016
    Posts
    1

    VBA Alternating between Portrait and Landscape to print

    Hi

    I am trying to alternate between Portrait and Landscape when printing a number of pages. The code ignores the change to Landscape and always prints Portrait even when the variable Qty value is greater than 6. Any help would be greatly appreciated

    Kindest regards

    Jack



    If Qty <= 6 Then
    Range("PrtArea").Select
    ActiveSheet.PageSetup.PrintArea = "PrtArea"
    Else
    Range("PrtArea2").Select
    ActiveSheet.PageSetup.PrintArea = "PrtArea2"
    End If

    Application.PrintCommunication = False
    With ActiveSheet.PageSetup
    .PrintTitleRows = "$1:$14"
    .PrintTitleColumns = ""
    End With
    Application.PrintCommunication = True
    Application.PrintCommunication = False
    With ActiveSheet.PageSetup
    .RightFooter = "&D &T"
    .LeftMargin = Application.CentimetersToPoints(1)
    .RightMargin = Application.CentimetersToPoints(1)
    .TopMargin = Application.CentimetersToPoints(1)
    .BottomMargin = Application.CentimetersToPoints(1.5)
    .HeaderMargin = Application.CentimetersToPoints(3)
    .FooterMargin = Application.CentimetersToPoints(1)
    .PrintHeadings = False
    .PrintGridlines = False
    .PrintComments = xlPrintSheetEnd
    .PrintQuality = 600
    .CenterHorizontally = True
    .CenterVertically = False
    If Qty <= 6 Then
    .Orientation = xlPortrait
    Else
    .Orientation = xlLandscape
    End If
    .Draft = False
    .PaperSize = xlPaperA4
    .FirstPageNumber = xlAutomatic
    .Order = xlDownThenOver
    .BlackAndWhite = False
    .Zoom = False
    .FitToPagesWide = 1
    .FitToPagesTall = 2
    .PrintErrors = xlPrintErrorsDisplayed
    .OddAndEvenPagesHeaderFooter = False
    .DifferentFirstPageHeaderFooter = False
    .ScaleWithDocHeaderFooter = True
    .AlignMarginsHeaderFooter = True
    End With
    Application.PrintCommunication = True
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
    IgnorePrintAreas:=False

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,522

    Re: VBA Alternating between Portrait and Landscape to print

    Read the Forum Rules before you continue. Rule #2 should be of interest to you.
    Qty is not set to mean anything.

    If you explain what you want to achieve, the code generated by the recorder can be shortened to a few lines I think.
    Last edited by jolivanes; 03-22-2021 at 12:57 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Print Orientation from Portrait to landscape?
    By bralew in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2017, 07:20 AM
  2. Print both Portrait and Landscape from same worksheet
    By briancoleman81 in forum Excel General
    Replies: 2
    Last Post: 12-04-2014, 10:12 AM
  3. Replies: 12
    Last Post: 08-11-2010, 04:54 PM
  4. Print in portrait and landscape
    By mshah in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-20-2008, 05:46 PM
  5. program to print some landscape, some portrait?
    By honestlylion in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-17-2006, 05:40 PM
  6. Portrait/Landscape print issue
    By honestlylion in forum Excel General
    Replies: 1
    Last Post: 02-17-2006, 01:40 PM
  7. Print both Portrait and Landscape - Excel
    By Georgie77 in forum Excel General
    Replies: 8
    Last Post: 05-31-2005, 08:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1