Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Option Buttons/Radio Buttons John Calder New Users to Excel 7 May 16th 08 03:51 AM
Form buttons vs. ActiveX Buttons GeorgeJ Excel Discussion (Misc queries) 3 August 11th 07 09:02 PM
have toggle buttons but everytime print preview buttons move TinSandhu Excel Discussion (Misc queries) 1 October 11th 06 02:57 PM
custom toolbar buttons are saved where? Excel loads twice bymistake and all my custom toolbar buttons get gone!!! Kevin Waite Excel Programming 2 March 3rd 04 03:31 PM
Control Buttons vs. Command Buttons Robert Gibson Excel Programming 1 October 13th 03 04:33 PM


All times are GMT +1. The time now is 05:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"