View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
marsou marsou is offline
external usenet poster
 
Posts: 10
Default And once again: X and Y Screen Coordinates of a Range

Thank you very much, okaizawa

I guess now I need to go and dig into the theory.
72, 96, dpi etc.
I don't know much about that. :")

Thnx again for your help.

Regards,
M

okaizawa wrote:
Hi,

"Int(ws.Columns(i).Width * px * z / 7200 + 0.5000001)" is equivalent to
Application.Round(ws.Columns(i).Width * (z / 100) * (px / 72), 0)

"* (z / 100)" means zooming.
"* (px / 72)" converts from points to pixels.
"Application.Round( ,0)" rounds to an integer.
this code converts each row and column, not a whole range.

it is just one of hypotheses about the design of PointsToScreenPixelsX
and PointsToScreenPixelsY. I don't know the reason actually.
the exact coordinates have been calculated so far on my pc in this way.

--
HTH,

okaizawa


marsou wrote:
Hi okaizawa,

Thank you very much for your response!!!!
As a matter of fact your solution solved my problem.
But I have a couple of questions for you and I would highly appreciate
if you could answer me.

The main part of your solution is:

x = ActiveWindow.PointsToScreenPix*elsX(0)
For i = 1 To r.Column - 1
x = x + Int(ws.Columns(i).Width * px * z / 7200 + 0.5000001)
Next


y = ActiveWindow.PointsToScreenPix*elsY(0)
For i = 1 To r.Row - 1
y = y + Int(ws.Rows(i).Height * py * z / 7200 + 0.5000001)
Next


Me.Left = x * 72 / px
Me.Top = y * 72 / py




In numbers.
for cell "A1", Zoom = 100 , LOGPIXELSX = 96 and LOGPIXELSY = 96 I get:
x = 28; y = 157 from PointsToScreen-s
and after the conversion suggested: x=21; y=117.75

Here are my questions
what do these numbers mean: 7200, 0.5000001, 72?

And another one: I am returning to my "bete noir"
PointsToScreenPix*elsX and PointsToScreenPix*elsY functions.
Aren't they supposed to return the coordinates of exact excel
point(even if conversion needed).
I mean why start with 0,0 point and then add all the widths(heigths) up
to selected range?


If you could answer my questions(especially the first one, because I'd
like to know what exactly did solve my problem :) )...

However thank you VEEEEEEERY much for your help.

Waiting for your answer,
Regards,
M