View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Stephen Bullen[_4_] Stephen Bullen[_4_] is offline
external usenet poster
 
Posts: 205
Default And once again: X and Y Screen Coordinates of a Range

Hi Marsou,

Now my problem here is that when I use this functions they are not
returning what I expect them to. For example if I get the screen
coordinates of Cell A1 and put there a user form, I was expecting that
the userform top left point will be at the top left of A1 cell. But it
is positioned a little lower and to the right. If I change the position
of the whole excel window and run the same macros, I expected that this
behaviour will be repeated, but now the form is displayed lower and
more to the right than the previous one - it looks like some
coefficient is multiplied.


We explain how to do this on page 325-326 of our book. Basically, you
create a embedded chart object at the range, then immediately delete it.
Excel has a window with a class name of EXCELE, which will be where the
chart object was, so we can use API calls to read the position of that
window (using FindWindowEx to get the handle and GetWindowRect to read
its position), then show the form there.

Regards

Stephen Bullen
Microsoft MVP - Excel

Professional Excel Development
The most advanced Excel VBA book available
www.oaltd.co.uk/ProExcelDev