Get points in a worksheet using mouse click

R

Rock

I am writing procedure in excel 2002 where I have imported a bitmap
image into a worksheet and I would like to digitize a few points (get
the x and y coordinates) when I click on the mouse.

I would like to press a macro button that would allow the user to
click on a lower left control point and an upper right control point
(points on the bmp that have known x and y values used for scaling)
and then draw a label control with corners through the control points.

I have searched the newsgroups, but have not seen how to do this.

Thanks for the help.

Rock
 
B

Bob Phillips

Rock,

Here is some code to get the cursor position, but I am not clear how you
will run it, as pressing a button moves the cursor.

Private Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long

Private Type POINTAPI
x As Long
y As Long
End Type

Sub test()
Dim pPosition As POINTAPI
Dim lReturn As Long

lReturn = GetCursorPos(pPosition)
MsgBox "Cursor position is:" & vbCrLf & _
"x co-ordinate: " & pPosition.x & vbCrLf & _
"y co-ordinate: " & pPosition.y

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
R

Rock

The initial button click will essentially prompt the user to click on
the two calibration points. The program needs to be able to aquire x
and y data points that are clicked and then using these points, create
a new label control with the lower left and upper right corners of the
control on the control points that were clicked.

Rock
 
B

Bob Phillips

I have some code to get the x & y points on a mouseover, I'll try and dig it
out and modify to mouse-click.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top