+ Reply to Thread
Results 1 to 6 of 6

PageSetup properties using variables

  1. #1
    Registered User
    Join Date
    07-02-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    3

    PageSetup properties using variables

    Hi

    I am getting error:
    Run-time error '1004': Unable to set the Orientation property of the PageSetup class

    I am using the following code:
    Please Login or Register  to view this content.
    In the .Orientation = StrOrientation section I have replaced the variable with "xlPortrait" and it works so I know it isn't a printer issue. I have entered the variable reference in incorrectly but I cannot work out where or how.


    Thanks in advance
    Last edited by froodo; 07-08-2009 at 08:25 PM. Reason: code tag

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: PageSetup properties using variables

    Hi froodo,

    Welcome to the forum.

    I may have a solution, but before I can suggest it you'll need to PM a moderator to have your code wrapped as your thread currently breaks Rule 3 of the forum (see here for more info).

    Once this is done I'll gladly post my suggested solution.

    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: PageSetup properties using variables

    Hi froodo,

    Thanks for that.

    As you've created a named range you don't have to assign its value to variable, i.e.

    Please Login or Register  to view this content.
    will work fine. If you really want to assign the value of the "Orientation" named range to a variable (which seems to me to be doubling handling), try this:

    Please Login or Register  to view this content.
    HTH

    Robert

  4. #4
    Registered User
    Join Date
    07-02-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: PageSetup properties using variables

    Thanks for your reply and help with forum etiquette, I still am receiving the same error when I use either of your methods. Any other ideas what may be wrong?


    Thanks

  5. #5
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: PageSetup properties using variables

    Hi froodo,

    The orientation options (i.e. Portrait or Landscape) must be returned as integers (1 or 2 respectively).

    Have a look at the following which checks the value in the "Orientation" named range to assign one of the two values to the "intPrintOrientation" accordingly. I've also included some notes to hopefully explain things:

    Please Login or Register  to view this content.
    HTH

    Robert

  6. #6
    Registered User
    Join Date
    07-02-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Smile Re: PageSetup properties using variables

    Thanks, that did the trick. I was thinking that the xlLandscape and xlPortrait would of have to of been used.

    Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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