I'm developing an application that ties into Word, and I'm trying to bind
certain key combinations to functions. When I run, I get the error " Runtime
error 5346 Word cannot change the function of the specified key"
I'm running Word XP on Windows XP Pro.
I'm using the following code in a template:
Private Sub Document_Open()
'bind ctl-shift-I to action
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyShift, wdKeyI),
KeyCategory:=wdKeyCategoryMacro, _
Command:="CutAndPaste"
End Sub
Private Sub CutAndPaste()
Dim tmp As WordTest2.clsWordFunctions
Set tmp = New WordTest2.clsWordFunctions
tmp.CutPaste ThisDocument
End Sub
Any help would be appreciated.
Alan
Stanbbury - 18 Mar 2005 01:37 GMT
Alan:
You want to bind the key to a macro called CutAndPaste. Here is a VBA
clip that binds Ctrl+M to the macro MakeStyles in the module ASA which
is inserted in a global template.
Dim cKeys As KeyBindings ' Create alias to shorten up code
Set cKeys = Word.KeyBindings
' Ctrl M = MakeStyles()
cKeys.Add _
KeyCode:=BuildKeyCode(wdKeyControl, wdKeyM), _
KeyCode2:=wdNoKey, _
KeyCategory:=wdKeyCategoryMacro, _
Command:="TemplateProject.ASA.MakeStyles", _
CommandParameter:=""
I wonder if you need to specify the template and module before Word
can fine the macro.
- Al
> I'm developing an application that ties into Word, and I'm trying to bind
> certain key combinations to functions. When I run, I get the error " Runtime
[quoted text clipped - 23 lines]
>
> Alan