Determining the keypress that got me here

B

Bear

How can I determine which key the user pressed to launch the macro I'm in?

The application is that I'd like to assign Alt+( and Alt+" to the same
macro, but enclose the selection either in parentheses or double quotes.

How can I tell which one the user pressed to launch the macro?

Bear
 
S

Shauna Kelly

Hi Bear

I'd write two macros that are shells to your 'real' macro. Eg:

Sub MacroA() ' called by Alt+"
'call the general macro with
'curly double quotes as delimiters
DoMyStuff sDelimiter1:=Chr(147), sDelimter2:=Chr(148)
End Sub

Sub MacroB() ' called by Alt+(
'call the general macro with
'parentheses as delimiters
DoMyStuff sDelimiter1:="(", sDelimiter2:=")"
End Sub

Sub DoMyStuff(sDelimiter1 As String, sDelimiter2 As String)
'main routine
End Sub


Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
B

Bear

Thanks Shauna. That's probably what I'll do. But I'd sure like to know if
there's a simple way to determine what keypress launched a given macro,
analogous to the ActionControl.

If anybody knows, please chime in. Shauna has given me a perfectly good
solution to my immediate problem, but I'm still curious.

Bear
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top