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
--
Windows XP, Word 2000

Re: Determining the keypress that got me here by Shauna

Shauna
Mon Oct 22 17:49:39 PDT 2007

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


"Bear" <david.chinell@ge.com(nospam)> wrote in message
news:3C35416F-FA76-495C-A725-B7B8903E0C31@microsoft.com...
> 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
> --
> Windows XP, Word 2000



Re: Determining the keypress that got me here by david

david
Tue Oct 23 06:12:01 PDT 2007

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
--
Windows XP, Word 2000


"Shauna Kelly" wrote:

> 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
>
>
> "Bear" <david.chinell@ge.com(nospam)> wrote in message
> news:3C35416F-FA76-495C-A725-B7B8903E0C31@microsoft.com...
> > 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
> > --
> > Windows XP, Word 2000
>
>
>