PointsToScreenPixels Documentation Incorrect
I think you are missing the important "(document coordinates)" though I
agree help is misleading.
Put a button on your sheet and assigned to -
Sub test()
With ActiveWindow
MsgBox .PointsToScreenPixelsX(0) & " " _
& .PointsToScreenPixelsY(0)
End With
End Sub
Copy the button and paste into say row 20000 (wider row headers) and run
again
Also 'Restore' the active window, move it down & to the right and reapeat
the macro. I imagine what the actually functions do will become clear.
For what I think you are looking for, (for most users not using large fonts)
the conversion is 72 points to 96 pixels (ie 3:4), though there's an API to
confirm.
Regards,
Peter T
"Lazzaroni" wrote in message
...
I ran this little piece of code to test the PointsToScreenPixelsX and
PointsToScreenPixelsY methods. It's better to run the code using a command
button placed on a spreadsheet, otherwise the active window may change to
a
window other than the one with the selected cells in, which causes the
methods to return 0.
Dim oCell As Range
For Each oCell In Selection
oCell.Value = "W = " & ActiveWindow.PointsToScreenPixelsX(oCell.Width)
& _
", H = " & ActiveWindow.PointsToScreenPixelsY(oCell.Height)
Next
According to the VBA documentation the methods "convert a vertical
measurement from points (document coordinates) to screen pixels (screen
coordinates). Returns the converted measurement as a Long value."
That doesn't appear to be the case. I can see what the pixel size of any
column or row is by adjusting the width using the column and row markings
on
the header. Whatever numbers PointsToScreenPixels is returning, they are
not
pixels.
In fact, there is an inverse relationship between the number returned and
the actual width or height of the column or row. In other words, if the
width
or height is larger, the value returned by PointsToScreenPixels is
smaller.
If anyone can help me sort out this mystery and retrieve the REAL width
and
height of any given column or row I would greatly appreciate it.
Thanks.
|