Thanks in advance and bye
Thomas
You can use the GetWindowPos API function to do this. Here's an example:
Public Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long
Public Type POINTAPI
x As Long
y As Long
End Type
Public Sub DisplayMousePosition()
Dim uPoint As POINTAPI
If GetCursorPos(uPoint) Then
MsgBox "X: " & CStr(uPoint.x) & " points" & vbLf _
& "Y: " & CStr(uPoint.y) & " points", vbInformation, _
"Mouse Coordinates"
Else
MsgBox "Error retrieving coordinates."
End If
End Sub
Regards,
Jake Marx
Thomas Wormser <comp...@nbg.netdiscounter.de> wrote in message
news:egkAAPam$GA.256@cppssbbsa05...
Have a nice day!
Thomas
Regards,
Tom Ogilvy
MVP Excel
Thomas Wormser <comp...@nbg.netdiscounter.de> wrote in message
news:#Qxc2atm$GA....@cppssbbsa02.microsoft.com...
I'm not sure exactly what you're looking for here. I was thinking you'd
want to know where the cursor was at any given moment. To do that, you'd
probably want to assign a shortcut (e.g. Ctrl+Shift+P) to the routine I gave
you before to display the current cursor position.
Here's another routine that might help you out. Basically, it will give you
the coordinates of any selected shape.
If this is not what you want either, you need to post back with more detail
so we know what you are looking for.
Regards,
Jake Marx
Sub GetShapeCoordinates()
Dim nLeft As Integer
Dim nRight As Integer
Dim nTop As Integer
Dim nBottom As Integer
On Error GoTo ErrHandler
If TypeOf Selection Is Object Then
With Selection
nLeft = .Left
nRight = nLeft + .Width
nTop = .Top
nBottom = nTop + .Height
End With
MsgBox "Left: " & CStr(nTop) & vbLf & _
"Right: " & CStr(nRight) & vbLf & _
"Top: " & CStr(nTop) & vbLf & _
"Bottom: " & CStr(nBottom), _
vbInformation, "Shape " & _
Selection.Name & " Coordinates"
End If
ExitRoutine:
Exit Sub
ErrHandler:
MsgBox "You must select a shape before running " & _
"this routine.", vbExclamation, "Error"
Resume ExitRoutine
End Sub
Regards,
Jake Marx
But I think, I have to tell you the context.
If it sounds complicated to you, then it's my bad English. I will do my
best.
OK!
In the past months I have made a mechanical calculation software. It's
programmed with Borland's Delphi.
With this software you can calculated the price of every sheet metal part
is this the correct definition? ).
This software is based on a big database and has also the CAD-possibilities
(drawing lines,circles,polygons and other objects).
The calculation works quit exactly, but for end-user it's not so easy to
understand.
At all the past rainy weekends I discovered EXCEL and little VBA
programming. You see, Jake, I am a beginner on this terrain.
The cell-functions of Excel I like very much, because they are quite easy.
So I started to make a "quick and easy" calculation. The excel file has to
sheets ("Calcul" and "Data").
Calcul takes user-prompts and shows results. Data sheet holds a small
"database".
My idea is to design the sheet metall parts in Excel.
A easy sheet metal part could look like this:
Now you see what I want to do.
In my opinion, I only can get positions, if it' possible to declare user
events on a worksheet. ( probably the events OnMouseDown and OnMouseUp )
If I can get each point (x,y position) of a line so I write them in an
array.
Afterwards I have to calculate the length of each line and sum up all lines.
The result of this crazy thing is to get the whole figure-size in inch
"mm" in Gemany).
Parts like the above one have to be manufactured on laser-cutting machines.
If I know the figure size of this part, I know the running time on the laser
machine.
That's the reason for all sleepless nights.
Perhaps You can help me.
Bye,
Thomas