ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Get page orientation of active sheet in Excel 2007 (https://www.excelbanter.com/excel-programming/396521-get-page-orientation-active-sheet-excel-2007-a.html)

Luca Brasi

Get page orientation of active sheet in Excel 2007
 
If a chart is selected in Excel 2007, using
ActiveSheet.PageSetup.Orientation doesn't seem to return the orientation
of the active sheet, but the orientation of the selected chart object
(whatever the meaning of this value is...?).

Is there another way to return the orientation of the active sheet (if
not programmatically unselect the chart shape first)?
Thanks

Luca Brasi

Get page orientation of active sheet in Excel 2007
 
doesn't work either... :(


Tom Ogilvy wrote:
What do you get with activesheet.name?

Dim sh as Worksheet
set sh = worksheets(Activesheet.name)

msgbox sh.pagesetup.orientation

of course, you don't need to select the chart to work with it.

activesheet.chartobjects(1).Select


Tom Ogilvy

Get page orientation of active sheet in Excel 2007
 

Sub ABCD()
Dim obj As Object
Set obj = Selection
Do While TypeName(obj) < "Worksheet"
Set obj = obj.Parent
Loop
MsgBox obj.PageSetup.Orientation
End Sub


--
Regards,
Tom Ogilvy


"Luca Brasi" wrote:

doesn't work either... :(


Tom Ogilvy wrote:
What do you get with activesheet.name?

Dim sh as Worksheet
set sh = worksheets(Activesheet.name)

msgbox sh.pagesetup.orientation

of course, you don't need to select the chart to work with it.

activesheet.chartobjects(1).Select



Luca Brasi

Get page orientation of active sheet in Excel 2007
 
Unfortunately no.

There's no problem to get the reference to the active worksheet. The
ActiveSheet property does this correctly.

But if a chart is selected on this sheet,
ActiveSheet.PageSetup.Oriention does not return the orientation of this
sheet, but the orientation of the selected chart object (whatever that
means). The same for PaperSize.

Thanks for your help anyway.


Tom Ogilvy wrote:
Sub ABCD()
Dim obj As Object
Set obj = Selection
Do While TypeName(obj) < "Worksheet"
Set obj = obj.Parent
Loop
MsgBox obj.PageSetup.Orientation
End Sub




All times are GMT +1. The time now is 09:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com