Handling Hotkey for File | Save menu item

R

Ram Prakash Singh

Hi,
How can I add a menu item in File Menu with a hotkey like
CTRL+S.

Secondly, I have overloaded the save menu item in word and
handling the event when File | Save is clicked in a word-
addin. It's working fine when File | Menu item is clicked.
But the event is not getting triggered when CTRL+S is
pressed from keyboard. How can I handle the CTRL+S ?

I tried to handle it using SetWindowsHookEx and then
catching the CTRL+S key but the hook is getting enabled
system-wide. Hence when word is running and same time if I
press CTRL+S in notepad, it's calling function in word-
addin. However when word is not running, presseing CTRL+S
in notepad works fine.

Regards,
RPSingh
 
C

Cindy M -WordMVP-

Hi Ram,

No one has answered this, yet. I don't really know an answer,
but I hope I can at least provide some background
information.

Word built-in menu items and keyboard shortcuts react are
linked to the built-in command names. If there's a procedure
in a valid context (standard module in the document, its
template, a global template) named the same as a command, the
procedure is exectued instead of Word's default behavior. A
procedure named FileSave, for example.

Using KeyBindings, you can assign a keyboard shortcut to any
public procedure in a standard module. But you can't assign a
keyboard shortcut to, say, an event in an Addin programmed in
C#. This requires a CALLBACK procedure in the correct context
in order to link the two.
How can I add a menu item in File Menu with a hotkey like
CTRL+S.

Secondly, I have overloaded the save menu item in word and
handling the event when File | Save is clicked in a word-
addin. It's working fine when File | Menu item is clicked.
But the event is not getting triggered when CTRL+S is
pressed from keyboard. How can I handle the CTRL+S ?

I tried to handle it using SetWindowsHookEx and then
catching the CTRL+S key but the hook is getting enabled
system-wide. Hence when word is running and same time if I
press CTRL+S in notepad, it's calling function in word-
addin. However when word is not running, presseing CTRL+S
in notepad works fine.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun
8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 

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