Link to home
Create AccountLog in
Avatar of Norma Posy
Norma PosyFlag for United States of America

asked on

Page orientation for an Excel object

What is the syntax for assigning the constant xlLandscape to an object set as an Excel spreadsheet?
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

It's part of the page setup.  So, if you have an object variable that is an Excel worksheet:


objWorksheet.PageSetup.Orientation = 2 'xlLandscape = 2

Open in new window

Avatar of Norma Posy

ASKER

I have collection of global  xl constants.
xlLandscape = 2 is one of them
=====
Dim oXL As Object
Set oXL = CreateObject("Excel.Application")
With oXL
    .Visible = True
    .Workbooks.Add
    .PageSetup.Orientation = xlLandscape ' <<<< Program bombs here



"Runtime error 438"
"Object doesn't support this property or method"
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Thank you.

It is a matter of what object has which property.