?
Solved

Landscape to Portrait?

Posted on 2003-03-19
6
Medium Priority
?
1,865 Views
Last Modified: 2012-06-21
Prtdevmode explains how to change the paper orientation, but using this code is complicated as the form has to be opened in design mode, the changes made, returned to normal view and several options reset.

Since its possible to manually select File/Page SetUp/Page and select portrait or landscape and update the page orientation without appearing to change the form to design view and returning the form the normal view I'm wondering how do do the same thing in VBA code, maybe the RunCommand could be used to do the same thing?   If so, what code would be needed or how I might find it?

Thanks

Elton
0
Comment
Question by:katzwhite
6 Comments
 
LVL 14

Accepted Solution

by:
mgrattan earned 2000 total points
ID: 8170697
Prtdevmode is the best way to do this in code.  You could use the Echo function to hide what's going on from the user though:

Echo False

Then, after you have completed your Landscape setting using the prtdevmode function you can set the Echo back to true:

Echo True

Another thing to try is the SendKeys function.  You can send the exact keystrokes that you are using to set the landscape mode manually using SendKeys.  I haven't tried it with this particular goal but it might be worth trying.
0
 
LVL 9

Expert Comment

by:mcallarse
ID: 8170809
Wouldn't recommend SendKeys, but I'm with mgrattan otherwise: PrtDevMode is probably the most efficient way to do this in code, though I'm sure that you can also change these properties using the Win32 API.

Take a look at the following:

http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/accessdev/html/ODC_MicrosoftOfficeDeveloperForumControllingYourPrinterinMicrosoftAccess.asp
0
 
LVL 5

Expert Comment

by:gwgaw
ID: 8171845
You can use the following to change the printer orientation in code while the form is in run mode. Although the print preview of the form will not change, the form will print correctly.

Me.Printer.Orientation = 1 change to portrait
Me.Printer.Orientation = 2 change to landscape

gaw
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 2

Expert Comment

by:TT2
ID: 8172704
If you want a straight fix for a report that you want to print in landscape mode, all the time... you can change the any of the Page Setup options (even specific printer) with the report in Design View and then save it whilst simultaneously holding-down the "Ctrl" key on the keyboard.  

Although undocumented, this works in Access 2K and I assume it will also work with other versions of Access, if yours is different.

Print Preview should also work correctly with the saved settings.

I hope I haven't got the "wrong end of the stick" with this comment and that it's relevant to your question.

Glen Ashton
0
 

Author Comment

by:katzwhite
ID: 8374985
Sorry to be so long in accepting this answer.  Forgot!

Thanks for the help

Elton
0
 
LVL 14

Expert Comment

by:mgrattan
ID: 8375558
No problem!
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question