Propiedad PageSetup.Orientation (Excel)

Devuelve o establece un valor XlPageOrientation que representa el modo de impresión vertical o horizontal.

Sintaxis

expresión. Orientación

Expresión Variable que representa un objeto PageSetup .

Ejemplo:

En este ejemplo se establece que Sheet1 se imprima en orientación horizontal.

Worksheets("Sheet1").PageSetup.Orientation = xlLandscape

En este ejemplo se establece que la hoja actualmente activa se imprima en orientación vertical.

ActiveSheet.PageSetup.Orientation = xlPortrait

Este procedimiento cambia la orientación a la opción opuesta.

Sub SwitchOrientation()
    Dim ps As PageSetup
    Set ps = ActiveSheet.PageSetup

    If ps.Orientation = xlLandscape Then
        ps.Orientation = xlPortrait
    Else
        ps.Orientation = xlLandscape
    End If
End Sub

Soporte técnico y comentarios

¿Tiene preguntas o comentarios sobre VBA para Office o esta documentación? Vea Soporte técnico y comentarios sobre VBA para Office para obtener ayuda sobre las formas en las que puede recibir soporte técnico y enviar comentarios.