Hot keys for a command button in UserForm in Excel programming 
Author Message
 Hot keys for a command button in UserForm in Excel programming

Hi all,
I want to assign a hot key (Like ctrl+h) to a command button in VBA UserForm.
On pressing that hot key i want to show some extra controls ont he UserForm.
How can assign hot key like that??

Thanks
Raj



Fri, 28 May 2004 16:32:56 GMT  
 Hot keys for a command button in UserForm in Excel programming
Hi Raj,

You can use the Accelerator property to do this (except it works with Alt,
not Ctrl).  If the letter you choose appears in the caption of the
CommandButton, that letter will be underlined as well.  Whatever code you
put in the CommandButton's Click event will execute when the hotkey is
pressed.

Regards,

Jake Marx
Excel MVP


Quote:
> Hi all,
> I want to assign a hot key (Like ctrl+h) to a command button in VBA
UserForm.
> On pressing that hot key i want to show some extra controls ont he
UserForm.
> How can assign hot key like that??

> Thanks
> Raj



Sat, 29 May 2004 02:47:08 GMT  
 Hot keys for a command button in UserForm in Excel programming
Raj

you need to set the Accelerator in the Properties for the Command Button

I think you can only have upper case letters or numbers (not tested
punctuation, etc)

Press Alt and the Accelerator Key to activate the Button.

From the VBA Help:

accelerator key

A single character used as a shortcut for selecting an object. Pressing the
ALT key, followed by the accelerator key gives focus to the object and
initiates one or more events associated with the object. The specific event
or events initiated varies from one object to another. If code is associated
with an event, it is processed when the event is initiated. Also called
keyboard accelerator, shortcut key, keyboard shortcut.

Remarks

To designate an accelerator key, enter a single character for the
Accelerator property. You can set Accelerator in the control's property
sheet or in code. If the value of this property contains more than one
character, the first character in the string becomes the value of
Accelerator.

When an accelerator key is used, there is no visual feedback (other than
focus) to indicate that the control initiated the Click event. For example,
if the accelerator key applies to a CommandButton, the user will not see the
button pressed in the interface. The button receives the focus, however,
when the user presses the accelerator key.

If the accelerator applies to a Label, the control following the Label in
the tab order, rather than the Label itself, receives the focus.

Regards

Trevor


Quote:
> Hi all,
> I want to assign a hot key (Like ctrl+h) to a command button in VBA
UserForm.
> On pressing that hot key i want to show some extra controls ont he
UserForm.
> How can assign hot key like that??

> Thanks
> Raj



Sat, 29 May 2004 02:57:44 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Reset Excel Hot Keys after Hot Keys customized ?

2. Hot Keys for tool bar buttons

3. Hot Key AIN'T SO HOT!

4. Tool bar button and hot/short cut key for a macro

5. Hot Keys for Existing Toolbar Buttons

6. Hot Keys in Excel

7. Excel 2001 Insert Hot Keys Changed!

8. Hot Key not working in Excel Macro

9. make userform button respond without alt key

10. Hot keys or short cut keys to call a presentation


 
Powered by phpBB® Forum Software © phpBB Group