Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

Error binding key to new function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AlanC - 16 Mar 2005 05:37 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.