#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Shortcut

Is it possible to assign a shortcut keystroke (ie Ctl U) to a sub procedure
if it resides in a private module?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Shortcut


Hello Steph,

If by private module you mean a module you inserted into your VB
project then the answer is yes. However, you can only assign a ho
combination that isn't in use. This example calls the Sub (macro
"RunProgram" in such a module. The Sub must be Public for this to work
Place this code in ThisWorkbook under Excel Objects in your project i
the Private Sub WorkBook_Open() procedure.

EXAMPLE
'Assign Keys CTRL + ALT + R to RunProgram Macro
Application.OnKey Key:="%^r", Procedu="RunProgram"

Shift = "+", CTRL = "%", ALT = "^"

To learn more about Key Codes see SendKeys Method in the VB Help.


Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=47770

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Shortcut

You can not assign a hot key to a private anything. If at the top of your
module you have...

option private module
then everything in the module is hidden adn the scope of everything in the
module is private.

If you have
Private Sub Test
then the scope of this procedure is private and once again you will not be
able to refernece it outside of the module.

By default whether explicitly stated or not everything else is Public. If
however your procedure takes arguments then you will not be able to assign a
hot key.

Public Sub Test
This is public and you can assign a hot key to it. Tools - Macros - Macros
- Options...
--
HTH...

Jim Thomlinson


"Steph" wrote:

Is it possible to assign a shortcut keystroke (ie Ctl U) to a sub procedure
if it resides in a private module?



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
shortcut has change or move so this shortcut can not open bakerstreet Excel Worksheet Functions 2 April 2nd 10 01:21 PM
Shortcut key?? Brad Excel Discussion (Misc queries) 1 October 19th 07 06:00 PM
Add-In Shortcut key xgirl Excel Programming 1 November 29th 04 09:47 PM
Shortcut Key ameliacat Excel Programming 1 October 23rd 04 05:03 PM
Shortcut key Hande Excel Programming 1 December 17th 03 10:19 AM


All times are GMT +1. The time now is 02:28 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"