Cannot change shortcut key for the selected macro ?

S

Sampath

Hi ,
I'm trying to attach a shortcut key to CommandBarButton using the KeyBinding
..
But i get an error saying that the key cannot be changed .
Can i get some code that does this.
I have seen some code snippets , i'm doing similar things in my app .
Can i get some sample programs that do this .. so that i can trace my error
easily


Thanks
Sampath
 
C

Cindy M -WordMVP-

Hi Sampath,

What command are you trying to attach to? Which keyboard combination? Version
of Word?

Show us the code you've tried?
I'm trying to attach a shortcut key to CommandBarButton using the KeyBinding
..
But i get an error saying that the key cannot be changed .
Can i get some code that does this.
I have seen some code snippets , i'm doing similar things in my app .
Can i get some sample programs that do this .. so that i can trace my error
easily

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
S

Sampath

Here is the code .

Private Sub IDTExtensibility2_OnConnection(ByVal Application As Object,
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst
As Object, custom() As Variant)

Set oApp = Application

Set omenuIsuite =
oApp.CommandBars("Tools").Controls.Add(Type:=msoControlPopup,
Temporary:=True, Before:=1)
omenuIsuite.Caption = "iS&uite"
omenuIsuite.Enabled = True


Set oitemSmartTags = omenuIsuite.Controls.Add( _
Type:=msoControlButton, Temporary:=True, Before:=1)
oitemSmartTags.Caption = "&Smart Tags"
oitemSmartTags.Tag = "ISuite Smart Tags Dialog"

Set oitemConfigure = omenuIsuite.Controls.Add( _
Type:=msoControlButton, Temporary:=True, Before:=1)
oitemConfigure.Caption = "&Configure"
oitemConfigure.Tag = "ISuite Smart Tags Configure"

????
oApp.KeyBindings.Add KeyCategory:=wdKeyCategoryCommand,
Command:="Configure_Dialog", KeyCode:=BuildKeyCode(wdKeyControl, wdKeyAlt,
wdKeyF12)
oApp.KeyBindings.Add KeyCategory:=wdKeyCategoryMacro,
Command:="SmartTag_Dialog", KeyCode:=BuildKeyCode(wdKeyControl, wdKeyAlt,
wdKeyF11)
????

I;m using IDTExtensibility2 and have added WithEvents to the
commandbarbutton
so mycontrols have a corresponsding click sub routine that gets trigerred .

Now i need to assign a shortcut .. How do it use the KeyBindings ?


-Sampath
 
C

Cindy M -WordMVP-

Hi Sampath,
I;m using IDTExtensibility2 and have added WithEvents to the
commandbarbutton
so mycontrols have a corresponsding click sub routine that gets trigerred .

Now i need to assign a shortcut .. How do it use the KeyBindings ?
You can assign a keyboard combination (keybinding) only to public procedures
saved in a valid Word project context. Basically, this means there has to be
a "macro" (Word VBA procedure) in the current document, its attached template
or in a global template.

If you want to call something in your addin, you'll need to use a macro in a
valid context as a callback to the procedure in the Addin.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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