Home |
Search |
Today's Posts |
#1
|
|||
|
|||
How to overwrite shortcut keys function in word
Hi,
We are in the process of building VSTO 2005 customizations for MS Word 2003. One of our requirement is to overwrite short cut keys function in word. Say for example, when a user presses ctrl+X keys the selected text should not be cut, that is the default function of ctrl+X should not be fired. Instead my function (Managed code and not a Macro) should be executed. We tried with Application.KeyBindings.Add but got the following error: Word cannot change the function of the specified key. Code: this.Application.KeyBindings.Add(WdKeyCategory.wdK eyCategoryCommand, "MenuItemNew1_Click", ThisApplication.BuildKeyCode(WdKey.wdKeyControl, ref objKeyX, ref missing, ref missing), ref missing, ref missing); Where MenuItemNew1_Click is a userdefined function. Any pointers in resolving the same will be appreciated. Thanks. |
#2
|
|||
|
|||
Hi Jay-
I don't claim to be aprogrammer, but on the basis of the example you gave (Ctrl+X), you may be looking to the wrong culprit. Many kybd shortcuts are _Windows_ based and merely supported within the applications. If you need to override them it may have to be done at the OS level. Regards |:) " wrote: Hi, We are in the process of building VSTO 2005 customizations for MS Word 2003. One of our requirement is to overwrite short cut keys function in word. Say for example, when a user presses ctrl+X keys the selected text should not be cut, that is the default function of ctrl+X should not be fired. Instead my function (Managed code and not a Macro) should be executed. We tried with Application.KeyBindings.Add but got the following error: Word cannot change the function of the specified key. Code: this.Application.KeyBindings.Add(WdKeyCategory.wdK eyCategoryCommand, "MenuItemNew1_Click", ThisApplication.BuildKeyCode(WdKey.wdKeyControl, ref objKeyX, ref missing, ref missing), ref missing, ref missing); Where MenuItemNew1_Click is a userdefined function. Any pointers in resolving the same will be appreciated. Thanks. |
#3
|
|||
|
|||
I was able to ovewrite ctrl-x by using it in a macro for word... not sure if
that's what you want to know or not. Other than that, I was only able to find a list of shortcuts by going to Windows Help and searching on "Keyboard shortcuts".... [I brought the ctrl-x back to being 'cut' by deleting the macro] " wrote: Hi, We are in the process of building VSTO 2005 customizations for MS Word 2003. One of our requirement is to overwrite short cut keys function in word. Say for example, when a user presses ctrl+X keys the selected text should not be cut, that is the default function of ctrl+X should not be fired. Instead my function (Managed code and not a Macro) should be executed. We tried with Application.KeyBindings.Add but got the following error: Word cannot change the function of the specified key. Code: this.Application.KeyBindings.Add(WdKeyCategory.wdK eyCategoryCommand, "MenuItemNew1_Click", ThisApplication.BuildKeyCode(WdKey.wdKeyControl, ref objKeyX, ref missing, ref missing), ref missing, ref missing); Where MenuItemNew1_Click is a userdefined function. Any pointers in resolving the same will be appreciated. Thanks. |
#4
|
|||
|
|||
Not sure how this would work in managed code, but the technique in VBA is
not to reassign the shortcut but to hijack the command. That is, if you write a macro named EditCut, then this will be performed when you press Ctrl+X instead of Word's built in Cut command. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA Word MVP FAQ site: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. wrote in message ps.com... Hi, We are in the process of building VSTO 2005 customizations for MS Word 2003. One of our requirement is to overwrite short cut keys function in word. Say for example, when a user presses ctrl+X keys the selected text should not be cut, that is the default function of ctrl+X should not be fired. Instead my function (Managed code and not a Macro) should be executed. We tried with Application.KeyBindings.Add but got the following error: Word cannot change the function of the specified key. Code: this.Application.KeyBindings.Add(WdKeyCategory.wdK eyCategoryCommand, "MenuItemNew1_Click", ThisApplication.BuildKeyCode(WdKey.wdKeyControl, ref objKeyX, ref missing, ref missing), ref missing, ref missing); Where MenuItemNew1_Click is a userdefined function. Any pointers in resolving the same will be appreciated. Thanks. |
#5
|
|||
|
|||
It is possible to set a KeyBinding to Ctrl+x. All that the message really
means is that it can't (at the moment) bind it to the command you're trying to use. The most likely reason is that it can't find - or can't bind to - the command. If MenuItemNew1_Click is already bound to an ActiveX CommandButton you can't bind to it. However, if you KeyBind to it before creating the button the keybinding will stick - I don't know if that's an option for you. If it's in a UserForm I'm not sure you can do it at all. Don't know how any of this works with VSTO, I'm afraid - nor any of the C# references (why objKeyX instead of wdKeyX for example? - and what is the diference between This.Application and ThisApplication?) -- Enjoy, Tony wrote in message ps.com... Hi, We are in the process of building VSTO 2005 customizations for MS Word 2003. One of our requirement is to overwrite short cut keys function in word. Say for example, when a user presses ctrl+X keys the selected text should not be cut, that is the default function of ctrl+X should not be fired. Instead my function (Managed code and not a Macro) should be executed. We tried with Application.KeyBindings.Add but got the following error: Word cannot change the function of the specified key. Code: this.Application.KeyBindings.Add(WdKeyCategory.wdK eyCategoryCommand, "MenuItemNew1_Click", ThisApplication.BuildKeyCode(WdKey.wdKeyControl, ref objKeyX, ref missing, ref missing), ref missing, ref missing); Where MenuItemNew1_Click is a userdefined function. Any pointers in resolving the same will be appreciated. Thanks. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Word2000 letterhead merge | Mailmerge | |||
Making Word do something that Wordperfect can do | New Users | |||
How do I get my default new document to always be our company let. | Microsoft Word Help | |||
WordPerfect keyboard macro>Word equivalent? | New Users | |||
creating forms | Microsoft Word Help |