Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default On Key press

I would like anytime I'm in Exel to be able to hit CRTL ALT ~ and call the
function testmsg.

Here is what I have:
Application.OnKey "^%{~}", "testmsg"

Does this look right?
I just put this in a new module but it is not picking up the key press.
Am I doing something wrong?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default On Key press

Hello
Why not directly assign a shortcut to your macro (I presume you are talking
about a macro and NOT a function in which case it could not work) ?
But anyway, to fire your macro with this special key combination, the code
(Application.OnKey "^%{~}", "testmsg") should be placed in a "Auto_Open"
macro or in the Workbook_Open event of a personnal.xls workbook.
The personnal.xls workbook contains macros that are available whenever Excel
is open.
To do this simply, use the macro recorder and select to record it into the
"Personnal Macros Workbook" from the list choice in the macro recording
dialog box (please note the option text may vary since I am using a French
version).
Then amend the macro you've recorded:
name it Auto_Open instead of default Macro1 and paste your code.
Close Excel and Answer Yes to save changes in the Personnal.xls.

Reopen Excel and test your code.

HTH
Cordially
Pascal

"pokdbz" a écrit dans le message de news:
...
I would like anytime I'm in Exel to be able to hit CRTL ALT ~ and call the
function testmsg.

Here is what I have:
Application.OnKey "^%{~}", "testmsg"

Does this look right?
I just put this in a new module but it is not picking up the key press.
Am I doing something wrong?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default On Key press

If I execute a macro with that command, then it works for me, but remember to
type a tilde you have to use the shift key, so it the combination actually
comes out to be

Ctrl+Alt+Shift+~

(it may be different on your keyboard, but that is the way it is for mine.
The tilde is the uppercase character on the left side of the number row (1st
key).

Sub ABC()
Application.OnKey "^%`", "testmsg"

End Sub

maybe what you actually want.

--
Regards,
Tom Ogilvy


"pokdbz" wrote:

I would like anytime I'm in Exel to be able to hit CRTL ALT ~ and call the
function testmsg.

Here is what I have:
Application.OnKey "^%{~}", "testmsg"

Does this look right?
I just put this in a new module but it is not picking up the key press.
Am I doing something wrong?

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
Key Press Event Todd Huttenstine Excel Programming 0 March 3rd 06 05:02 PM
When I Press the Enter Key Nothing happens. bigev Excel Discussion (Misc queries) 1 March 1st 06 03:05 PM
key press event? short_n_curly[_19_] Excel Programming 2 July 15th 05 08:43 PM
on press Fraggs[_18_] Excel Programming 1 June 7th 04 05:16 PM
on press detection Fraggs[_17_] Excel Programming 1 June 7th 04 03:26 PM


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