Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts

    switching between portrait and landscape

    Hi

    Just wondering if there is a different way to 'toggle' between landscape and portrait orientation? I have done as follows but feel that there must be a better/simpler way of doing it. Any comments?

    Code:
    Function switchOrientation(curOrientation As Variant) As Variant
        If curOrientation = wdOrientLandscape Then
            switchOrientation = wdOrientPortrait
        Else
            switchOrientation = wdOrientLandscape
        End If
    End Function
    
    in the code
    toggledOrientation= switchOrientation(Selection.PageSetup.Orientation)
    ...
    ...(
    Thanks.
    Robie

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    The best I can come up with is
    Code:
      With ActiveDocument.Sections(1).PageSetup
        .Orientation = (.Orientation + 1) Mod 2
      End With
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts
    I use the following code to toggle the section where the cursor is sitting:

    Sub ToggleOrientationThisSection()
    Dim lSection As Long
    Dim rng As Range
    ' Determine current section
    Set rng = ActiveDocument.Range(Start:=0, End:=Selection.End)
    lSection = rng.Sections.Count
    ' if Landscape, make Portrait; if Portrait, make Landscape
    If ActiveDocument.Sections(lSection).PageSetup.Orient ation = wdOrientLandscape Then
    ActiveDocument.Sections(lSection).PageSetup.Orient ation = wdOrientPortrait
    Else
    ActiveDocument.Sections(lSection).PageSetup.Orient ation = wdOrientLandscape
    End If

    End Sub

Posting Permissions

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