Shortcut to C# code via VBA in Word 2007?

H

happysad

Hello,

I asked this question in the Visual Studio Tools for Office forum, and was
told it could not be done without VBA code.

How do I create a keyboard shortcut (defined by myself or overriding a
built-in one) to call some c# code? I already have a command button for my
code on the Ribbon, and an item in the context menu, but what I really need
is a keyboard shortcut.

I am a c#/.net developer unfamiliar with VBA, so please include all steps in
getting the necessary VBA code to work...
 
B

Bear

Happysad:

Here's the macro that gets recorded in VBA when I use the Word GUI to assign
Ctrl+Shift+Alt+X to the File > Close command.

Sub x()
'
' x Macro
' Macro recorded 4/9/2008 by David Chinell
'
CustomizationContext = ActiveDocument.AttachedTemplate
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyX, wdKeyControl, wdKeyShift, _
wdKeyAlt), KeyCategory:=wdKeyCategoryCommand, Command:="FileClose"
End Sub

The customization context is the template where this shortcut is stored. You
may want to use NormalTemplate in place of the AttachedTemplate.
 

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