ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Calculate vertical midpoint of a print area in a sheet (https://www.excelbanter.com/excel-programming/291598-calculate-vertical-midpoint-print-area-sheet.html)

quartz

Calculate vertical midpoint of a print area in a sheet
 
Is it even possible to calculate the midpoint of a sheet taking into account margins, row heights, font sizes, and anything else that could affect it

I am trying to place a graphic (a text box) at the left edge (horizontal) and center of the page (vertical) using VBA. The sheets I have to work with use all different font sizes, margins, row heights, etc. It seems impossible to do.

Have I found a limit in VBA

If you can accurately calculate this, please, pleasE, pleaSE, pleASE, plEASE, pLEASE, PLEASE post your code so I can solve this mystery.

Thanks much in advance for your assistance


Tom Ogilvy

Calculate vertical midpoint of a print area in a sheet
 
Seems you could find the pagebreak, then add up the heights of the rows in
the page, then go halfway.

--
Regards,
Tom Ogilvy

"quartz" wrote in message
...
Is it even possible to calculate the midpoint of a sheet taking into

account margins, row heights, font sizes, and anything else that could
affect it?

I am trying to place a graphic (a text box) at the left edge (horizontal)

and center of the page (vertical) using VBA. The sheets I have to work with
use all different font sizes, margins, row heights, etc. It seems impossible
to do.

Have I found a limit in VBA?

If you can accurately calculate this, please, pleasE, pleaSE, pleASE,

plEASE, pLEASE, PLEASE post your code so I can solve this mystery.

Thanks much in advance for your assistance.




BrianB

Calculate vertical midpoint of a print area in a sheet
 
This will work if :-
1. There is only 1 page.
2. The Print Range is set (or you can supply another range)

'----------------------------------------------------
Sub test()
'- requires that Print area is set
Dim TotalRowHeight As Long
Dim PictureHeight As Long
'-- calculate height
TotalRowHeight = 0
For Each RW In ActiveSheet.Range("Print_Area").Rows
TotalRowHeight = TotalRowHeight + RW.RowHeight
Next
'- change picture position
PictureHeight = ActiveSheet.OLEObjects("Object 1").Height
ActiveSheet.OLEObjects("Object 1").Top = (TotalRowHeight / 2)
(PictureHeight / 2)
End Sub
'--------------------------------------------

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 06:51 PM.

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