• switching between portrait and landscape

    Author
    Topic
    #477222

    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)
    …
    …(
    Viewing 0 reply threads
    Author
    Replies
    • #1283530

      The best I can come up with is

      Code:
        With ActiveDocument.Sections(1).PageSetup
          .Orientation = (.Orientation + 1) Mod 2
        End With
      • #1288640

        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.Orientation = wdOrientLandscape Then
        ActiveDocument.Sections(lSection).PageSetup.Orientation = wdOrientPortrait
        Else
        ActiveDocument.Sections(lSection).PageSetup.Orientation = wdOrientLandscape
        End If

        End Sub

    Viewing 0 reply threads
    Reply To: switching between portrait and landscape

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: