Results 1 to 7 of 7
  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Which Key? (Word 97SR2)

    If I have two key combinations that invoke the same macro, is there a way to tell in that macro which of the two key combos was pressed to invoke the macro?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  2. #2
    Star Lounger
    Join Date
    Jan 2001
    Location
    Upstate NY, New York, USA
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Which Key? (Word 97SR2)

    Hey Kev... not sure but you should be able to write something with the KeyPress Event...

  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Which Key? (Word 97SR2)

    The Keypress event is only available from a userform or control on a form. One of the most glaring omissions in Word is a global keypress event in the document or application objects.

    The only way to simulate such an event is to trap keystrokes via keybinding -- Klaus gets the credit in my book for being the first to point this out.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  4. #4
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Which Key? (Word 97SR2)

    <pre></pre>

    Given that AFAIK you can't set the same shortcuts in the same document/template, I think you're probably back to the old document/template hierarchy conundrum; which you can probably recite far better than me. HTH
    Gre

  5. #5
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Which Key? (Word 97SR2)

    Don't remember that... and it wasn't my idea.

    I've seen a template by Bill Coan where he traps each and every key with a keybinding...
    Lots of code, but it seemed to work fine.

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> Klaus

    ...and sorry,no, I don't have a solution for your problem -- except maybe have two macros with the two shortcuts (and one macro calling the other)...

  6. #6
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Which Key? (Word 97SR2)

    Hi Klaus

    Do you think that you can still locate that template by Bill Coan?

    On your thought of trapping the Key Code with two procedures; I can see a solution with three but not two. Would you care to share the details?
    <pre>Sub KeyCaptureY()
    ' This procedure invoked with Alt+Y
    Call DisplayKey("Alt+Y")
    End Sub
    ----------------------------------------------
    Sub KeyCaptureZ()
    ' This procedure invoked with Alt+Z
    Call DisplayKey("Alt+Z")
    End Sub
    ----------------------------------------------
    Sub DisplayKey(CallingKey As String)
    MsgBox CallingKey
    End Sub
    </pre>

    Regards
    Don

  7. #7
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Which Key? (Word 97SR2)

    I've seen the template only in action during a webcast presentation by Bill.
    But there wasn't anything special about the code as far as I could tell, just lots and lots of keybindings for all the keys (and Alt/Ctrl/Shift combinations).

    You're right about three procedures being necessary (or two with duplicate code, which would be bad for maintenance). I didn't think it through, it seems...

    <img src=/S/grin.gif border=0 alt=grin width=15 height=15> Klaus

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •