I guess you were talking about Excel?
I am having this problem with Word 2007
An old 2003 macro used to work which used
For Each oSection In ActiveDocument.Sections
If oSection.PageSetup.Orientation = wdOrientPortrait Then
It was not responding correctly I didn't mess much with it and switched to
For Each oSection In ActiveDocument.Sections
oSection.Range.Select
If Selection.PageSetup.Orientation = wdOrientPortrait Then
Never mind the oSection.Range.Select, when single stepping and manually placing the selection it didn't work right. And issuing
?Selection.PageSetup.Orientation in the immediate window.
It seemed to respond only to my clicking the landscape/portrait buttons on the ribbon. (not to the actual orientation of the page the cursor was on (selection). And since it toggled when the buttons were pressed instead of what the selected page actually was then it would appear to be working 50% of the time depending on what the page was that you first changed the orientation.
Then I also saw it respond once, and only once to moving the cursor with the mouse. I clicked on a portrait page and re-evaluated ?Selection.PageSetup.Orientation. and it toggled from wdOrientLandscape (0) to wdOrientPortrait (1)
But i could not reproduce this. It returned to responding only to the buttons. There is a chance I mixed a orientation button press and contaminated that one occurance. I may have forgotten to evaluate before clicking to ensure that it was actually the click that changed the value. And I could not reproduce it . . .
I think it is totally broken. How in the world would it become disconnected from the page/selection object and connected to the interface.
Unless there is a improperly controlled property of the page that somehow gets out of phase with the actual orientation.
It is like some kind of prank. Really annoying.
I guess I may have to compare height and width as the Excel solution did.
EagleOn wrote:
Re: Pagesetup.Orientation need VBA routine to "Best Guess" Orientation
04-May-07
Thanks Jon
Previous Posts In This Thread:
Pagesetup.Orientation need VBA routine to "Best Guess" Orientation
2003/2007
What parameters/settings with PageSetup could provide assist with calculating
PageOrientation to be placed in a macro to "best guess" it?
i.e. .Orientation = IIf (height > 2 * width AND Columns.count < 9),"Portrait","Landscape")
Is there a way to use inches in the height/width calculation?
Is there a better approach?
TIA EagleOne
Your algorithm is a good start. Use the range.width or .
Your algorithm is a good start. Use the range.width or .height and multiply
the results (in points) by 72 to get inches.
I can't think of a better way.
- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______
Re: Pagesetup.Orientation need VBA routine to "Best Guess" Orientation
Thanks Jon
EggHeadCafe - Software Developer Portal of Choice
Book Review: Silverlight 3 Programmer's Reference [Wrox]
http://www.eggheadcafe.com/tutorial...c74-f84ab694588b/book-review-silverlight.aspx