Printer Orientation Control using VBA Code

50 pts.
Tags:
VBA
VBA editor
Visual Basic
Visual Basic developers
I want to print excel UserForms automatically using VBA proceedures.Some should print in Portrait and others in Landscape. How can I control the printer page orientation from VBA code?

Software/Hardware used:
Excel 2007, HP All in One
ASKED: May 29, 2011  9:29 PM
UPDATED: June 1, 2011  6:07 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

I appreciate the answer provided by TIsanders1. Unfortunately I do not want to print an excel page. I want to print forms that I created in an excel file, The forms contain Textboxes, Command Buttons etc., and information input by a User. The code that was provided, –Worksheets(”Sheet1″).PageSetup.Orientation = xlLandscape — will change the page orientation of an excel worksheet but not a UserForm.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • tlsanders1
    This is from Excel 2003 Help. Maybe it will work for you. Worksheets("Sheet1").PageSetup.Orientation = xlLandscape
    1,340 pointsBadges:
    report
  • tlsanders1
    Sorry, I did not pick up on the UserForm part of the question. I've just been looking at various sites online and found hundreds of posts asking the same question with no good answers. One answer gave a lot of code lines to create a snapshot of the form, load it into another worksheet then print from there. So it would seem that the real answer is that it is not possible with a reasonable amount of effort.
    1,340 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following