Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Buttons in Excel VBA
I know that an event is fired when a button is clicked ( Button1_Click() ). I
would like to know if an event is fired when a button is RELEASED. I can't seem to find any information about it. Any help will be appreciated. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Buttons in Excel VBA
For a Forms Button (from the forms toolbar) the "release" of the button is
actually part of the Click event - if you try this code: Sub Button1_Click() MsgBox "Click!" End Sub you can press and hold in the button with no message, when you release you get "Click!" It is a bit different for the CommandButton from the Controls toolbox: This has 3 events called MouseDown, MouseUp, and Click. They occur in that order. Try creating these 3 Subs: Sub CommandButton1_MouseDown() MsgBox "MouseDown!" End Sub Sub CommandButton1_MouseUp() MsgBox "MouseUp!" End Sub Sub CommandButton1_Click() MsgBox "Click!" End Sub As written, if you press the button you will only see the MouseDown! message. If you erase the MouseDown event procedure you will then see only the MouseUp! message; if you only have the Click procedure you will see - of course - Click! -- - K Dales "misc1111" wrote: I know that an event is fired when a button is clicked ( Button1_Click() ). I would like to know if an event is fired when a button is RELEASED. I can't seem to find any information about it. Any help will be appreciated. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Buttons in Excel VBA
Hooray !! That code worked great. Thanks for your help.
"K Dales" wrote: For a Forms Button (from the forms toolbar) the "release" of the button is actually part of the Click event - if you try this code: Sub Button1_Click() MsgBox "Click!" End Sub you can press and hold in the button with no message, when you release you get "Click!" It is a bit different for the CommandButton from the Controls toolbox: This has 3 events called MouseDown, MouseUp, and Click. They occur in that order. Try creating these 3 Subs: Sub CommandButton1_MouseDown() MsgBox "MouseDown!" End Sub Sub CommandButton1_MouseUp() MsgBox "MouseUp!" End Sub Sub CommandButton1_Click() MsgBox "Click!" End Sub As written, if you press the button you will only see the MouseDown! message. If you erase the MouseDown event procedure you will then see only the MouseUp! message; if you only have the Click procedure you will see - of course - Click! -- - K Dales "misc1111" wrote: I know that an event is fired when a button is clicked ( Button1_Click() ). I would like to know if an event is fired when a button is RELEASED. I can't seem to find any information about it. Any help will be appreciated. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Option Buttons/Radio Buttons | New Users to Excel | |||
Form buttons vs. ActiveX Buttons | Excel Discussion (Misc queries) | |||
have toggle buttons but everytime print preview buttons move | Excel Discussion (Misc queries) | |||
custom toolbar buttons are saved where? Excel loads twice bymistake and all my custom toolbar buttons get gone!!! | Excel Programming | |||
Control Buttons vs. Command Buttons | Excel Programming |