Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default short key to invoke command button in userform

hi - I've got a userfomr that has a "Save & Close" command button which saves
the user entry back to a database.....is ther a way to invoke the command
button by using ctrl + s ......instead of having to click the command
button....i would like to allow for this to work both ways....

thanks
Amit.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default short key to invoke command button in userform

Hi Amit,

See the Acceleror property in VBA help.

In the Userform's module try something like:


=========
Private Sub UserForm_Initialize()
Const sAccelerator As String = "s"

Me.CommandButton1.Accelerator = sAccelerator

End Sub
<<=========

Note that this acelerator key would be invoked
with the Alt-s key combination.



---
Regards.
Norman


"amit" wrote in message
...
hi - I've got a userfomr that has a "Save & Close" command button which
saves
the user entry back to a database.....is ther a way to invoke the command
button by using ctrl + s ......instead of having to click the command
button....i would like to allow for this to work both ways....

thanks
Amit.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default short key to invoke command button in userform

See the Acceleror property in VBA help.

====

See the Accelerator property in VBA help.




---
Regards.
Norman
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default short key to invoke command button in userform

On 10 May, 09:50, amit wrote:
hi - I've got a userfomr that has a "Save & Close" command button which saves
the user entry back to a database.....is ther a way to invoke the command
button by using ctrl + s


See http://msdn.microsoft.com/en-us/libr...ffice.11).aspx

You need a line somewhere whch says
Application.Onkey "^s", "MySaveCloseRoutine"

Either put in in the form_activate event code and then disable it
again in form_deactivate if you only want it to be active with the
form open, or put it in Workbook_Open and deactivate in
Workbook_BeforeClose if you want it to work all the time.

I have a (stupidly) huge VBA Macro which has subverted all the Excel
menu commands and keyboard shortcuts in this way so that users can
exchange data files without sending out a copy of the macro/
application with each one. This sounds not dissimilar to what you are
trying to do.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default short key to invoke command button in userform

Hi AtpGroups,

I suspect that it was your intention to respond
to Armit rather than to me.

Since, however you have appended your
response to my post, see my reply to Armit
and note thata CommandButton has an
Accelerator property.




---
Regards.
Norman


"atpgroups" wrote in message
...
On 10 May, 09:50, amit wrote:
hi - I've got a userfomr that has a "Save & Close" command button which
saves
the user entry back to a database.....is ther a way to invoke the command
button by using ctrl + s


See http://msdn.microsoft.com/en-us/libr...ffice.11).aspx

You need a line somewhere whch says
Application.Onkey "^s", "MySaveCloseRoutine"

Either put in in the form_activate event code and then disable it
again in form_deactivate if you only want it to be active with the
form open, or put it in Workbook_Open and deactivate in
Workbook_BeforeClose if you want it to work all the time.

I have a (stupidly) huge VBA Macro which has subverted all the Excel
menu commands and keyboard shortcuts in this way so that users can
exchange data files without sending out a copy of the macro/
application with each one. This sounds not dissimilar to what you are
trying to do.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default short key to invoke command button in userform

thank Norman........this worked for me....

regards,
Amit

"Norman Jones" wrote:

Hi AtpGroups,

I suspect that it was your intention to respond
to Armit rather than to me.

Since, however you have appended your
response to my post, see my reply to Armit
and note thata CommandButton has an
Accelerator property.




---
Regards.
Norman


"atpgroups" wrote in message
...
On 10 May, 09:50, amit wrote:
hi - I've got a userfomr that has a "Save & Close" command button which
saves
the user entry back to a database.....is ther a way to invoke the command
button by using ctrl + s


See http://msdn.microsoft.com/en-us/libr...ffice.11).aspx

You need a line somewhere whch says
Application.Onkey "^s", "MySaveCloseRoutine"

Either put in in the form_activate event code and then disable it
again in form_deactivate if you only want it to be active with the
form open, or put it in Workbook_Open and deactivate in
Workbook_BeforeClose if you want it to work all the time.

I have a (stupidly) huge VBA Macro which has subverted all the Excel
menu commands and keyboard shortcuts in this way so that users can
exchange data files without sending out a copy of the macro/
application with each one. This sounds not dissimilar to what you are
trying to do.


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
How to get userform Cancel button to invoke Exit Sub in calling macro? Craig Remillard New Users to Excel 1 November 19th 09 03:55 AM
Use Command Button from each Row to fill UserForm RyanH Excel Programming 0 September 20th 07 01:24 PM
need to minimize userform via command button on itself Jed[_3_] Excel Programming 1 August 10th 06 09:39 PM
Specifying a Command Button on a worksheet as differentiated from one on a UserForm Amber_D_Laws[_52_] Excel Programming 14 February 7th 06 03:43 PM
Userform disappears when you try to initialize from a command button RPIJG[_60_] Excel Programming 8 July 2nd 04 08:14 PM


All times are GMT +1. The time now is 10:31 PM.

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

About Us

"It's about Microsoft Excel"