Page Size

DannyDont

New Member
Joined
Mar 7, 2014
Messages
40
I am attempting to find the usable page size so that I can set Page Breaks in VBA. I have it working with the following code. But it is only guess work. I would like to be able to know when I am going to overflow the bottom of the usable space rather that guessing at how big it is. There is probably a setting that tells me that but can't seem to find it.

'*******************************************
'*******************************************
Sub UTY_Get_Page_Height()
'*******************************************
'*******************************************
' Control_Page_Height_Begin
' Control_Page_Height_End
' Control_Row_Highest
' Control_Row_Lowest
'Stop
Set Control_Page_Height_Begin = ActiveSheet.Range("A1:F" & Control_Row_Lowest)
Set Control_Page_Height_End = ActiveSheet.Range("A1:F" & Control_Row_Highest)
If Control_Page_Height_End.Height - _
Control_Page_Height_Begin.Height > 450 Then
Control_Row_Type_Hold = Control_Row_Type
ActiveSheet.HPageBreaks.Add Before:=Range("A" & Control_Row_Highest + 1)
UTY_Set_Page_Headers
Control_Row_Type = Control_Row_Type_Hold
Control_Row_Lowest = Control_Row_Highest
End If
End Sub

I have looked at TopMargin and BottomMargin but they do not report the values that I need (want). If I knew the total size of a page (Portrait or Landscape) then I could use these margins. Current I have margins set to .25 inches which returns a value of 18 (unconverted to inches) and am in Landscape.

If I knew the total size of a page, then I could determine when to set the Page Break ... I believe.

Any help or other ideas would be most helpful.

Thanks to all
 
Last edited:

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top