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 / November 2004

Tip: Looking for answers? Try searching our database.

KeyBinding for Alt+C and Alt+N

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tim - 16 Nov 2004 21:09 GMT
When I try to add keybindings to Alt+C and Alt+N, I get a Run-time
error '5346'.
"Word cannot change the function of the specified key."

Below is a sample of the lines of code.

CustomizationContext = ActiveDocument.AttachedTemplate
KeyBindings.Add KeyCategory:=wdKeyCategoryCommand,
Command:="ToolBarMenu.InsertCautionBP", _
 KeyCode:=BuildKeyCode(arg1:=wdKeyAlt, arg2:=wdKeyC)

What is Alt+C & Alt+N suppose to do?
Is there a way around it?

Appreciate all Help.

Thanks,
Signature

Tim

Jean-Guy Marcil - 17 Nov 2004 03:23 GMT
Tim was telling us:
Tim nous racontait que :

> When I try to add keybindings to Alt+C and Alt+N, I get a Run-time
> error '5346'.
[quoted text clipped - 9 lines]
> What is Alt+C & Alt+N suppose to do?
> Is there a way around it?

I think the problem lies with
   "ToolBarMenu.InsertCautionBP"
Word cannot recognize this, hence it cannot create the bind the key
combination. Is ToolBarMenu the name of a module, a sub, a project...
IIRC, ALT+C and ALT+N are not assigned to anything, so it should not be a
problem to bind anything you want to them.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Tim - 17 Nov 2004 14:19 GMT
Thanks, you are correct. The problem does lie within
"ToolBarMenu.InsertCautionBP". ToolBarMenu is a module and
InsertCautionBP is a procedure. The problem is that
this procedure is expecting  a argument.

Thanks for the Help.

Tim

> Tim was telling us:
> Tim nous racontait que :
[quoted text clipped - 19 lines]
> IIRC, ALT+C and ALT+N are not assigned to anything, so it should not be a
> problem to bind anything you want to them.
Jonathan West - 17 Nov 2004 16:48 GMT
> Thanks, you are correct. The problem does lie within
> "ToolBarMenu.InsertCautionBP". ToolBarMenu is a module and
> InsertCautionBP is a procedure. The problem is that
> this procedure is expecting  a argument.
>
> Thanks for the Help.

Hi Tim,

The OnAction property can only be set to a VBA routine which meets all the
following conditions

- A public Sub
- In a module (as opposed to a Class for UserForm)
- with no parameters

If you want to be able to pass a paramater to a from the button, it can be
done, but it is a bit convoluted.

Every Commandbutton has a Tag property. You can't set the Tag from within
the user interface, but you can in code. Suppose you have set the tag, you
can then do something like this

Dim strTag as Tag
If CommandBars.ActionControl Is Nothing Then
   'not called from a button
   MsgBox "the macro wasn't called by clicking a toolbar button"
   Exit
Else
   strTag = CommandBars.ActionControl.Tag
End If
'Now you can use the value of strTag in your macro

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

Jean-Guy Marcil - 17 Nov 2004 17:16 GMT
Jonathan West was telling us:
Jonathan West nous racontait que :

> Hi Tim,
>
[quoted text clipped - 21 lines]
> End If
> 'Now you can use the value of strTag in your macro

Sorry Jonathan, just to be sure I did not miss something here...
The OP was writing about KeyBinding to a macro... Aren't OnAction property
for commandbar controls?
How do you make the connection to a keyboard shortcut?

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

 
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.