Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
vba, excel, commandbutton1_click() x,y?
is there a way (As in vb6) to pass the x,y cordinates of where yo
pressed on a commandbutton that is on a worksheet to a variable in macro? I'm thinking of vb6 : sub command_up(x,y, shift) (or something similar) xcord= x ycord=y end sub thank you. you guys are great -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
vba, excel, commandbutton1_click() x,y?
Jim,
The CommandButton does have a "Mouse_Down" and "Mouse_Up" event. Below is some code assuming you have a commandbutton named "CommandButton1" created on Sheet1. This should get you started. Troy ========================================== On a standard module, declare the following two global variables: ========================================== Public PsngCursorX As Single Public PsngCursorY As Single =================================== On the Sheet1 codepane, include these two Events: =================================== Private Sub CommandButton1_Click() MsgBox "Mouse: X=" & PsngCursorX & ", Y=" & PsngCursorY End Sub Private Sub CommandButton1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) PsngCursorX = X PsngCursorY = Y End Sub "jimx " wrote in message ... is there a way (As in vb6) to pass the x,y cordinates of where you pressed on a commandbutton that is on a worksheet to a variable in a macro? I'm thinking of vb6 : sub command_up(x,y, shift) (or something similar) xcord= x ycord=y end sub thank you. you guys are great! --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Private Sub CommandButton1_Click() | Excel Discussion (Misc queries) |