Keyboard shortcuts to call custom code

A

AlanC

Is it possible to bind a keyboard shortcut (e.g. Ctrl - j) to a function
within a COM add-in?
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?QWxhbkM=?=,
Is it possible to bind a keyboard shortcut (e.g. Ctrl - j) to a function
within a COM add-in?
It requires a callback function in the Office file's VBA project.

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 :)
 
A

AlanC

Is there any way to avoid putting code in a template? I'm developing an
add-in that will be widely distributed, and it seems that putting code in
templates could cause problems. I have plenty of C++ experience, so if there
is some way to do this with ugly COM code, I'll be happy to try.

Thanks,

Alan
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?QWxhbkM=?=,
Is there any way to avoid putting code in a template? I'm developing an
add-in that will be widely distributed, and it seems that putting code in
templates could cause problems. I have plenty of C++ experience, so if there
is some way to do this with ugly COM code, I'll be happy to try.
No, I'm afraid it's not possible. Keyboard shortcuts in Word can only be
assigned to things in a "Word context", which for code means code in a Word VBA
project. And Word locks API keyboard calls out.

Closest you could get would be to create the necessary procedures in the
document on the fly. But that will give you even more problems than putting code
in the template, then signing it with a digital signature / certificate. If you
have a signed VBA project, and the person installing it trusts your certificate,
it should install and run with no problem with a "High" macro security setting.
Only people who've set "Very High" (only available in Word 2003) would get
"locked out".

One other possibility, if your Addin is accessible via toolbars IN the template,
would be to assign these buttons accelerator keys (Alt+something) by using
ampersands in the caption (which must be visible). &Xyz would be accessible
using Alt+X, for example. You just have to watch out that you don't use
shortcuts already assigned to Word's menus.

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