attaching keyboard shortcuts to functions inside the COM add-in (Word)

D

Denis Dmitriev

Hello,

I'm looking for a way to attach keyboard shortcuts to the CommandBar buttons
my COM add-in creates (the add-in is hosted in Word, but a solution that'd
also work in PowerPoint would be nice), preferrably without using any VBA
glue. Unfortunately, I don't have the luxury of picking my own shortcuts
right now, and the ones I have to use cannot be handled by adding a
strategically placed ampersand to the caption.

I tried playing around with KeyBindings, but this went nowhere, as the
callbacks into the add-in are neither commands nor macros (hence, for
example, binding a key to
`Application.COMAddIns.Item(...).Object.ButtonPress(1)` didn't work).

I'm trying to stay away from creating VBA macros at runtime as that'd
pollute user documents. Also, while VBA glue could be placed in a template,
installing it in all the right user accounts is a mess and a maintenance
issue. As for the COM add-in loading a global template at run-time---it
sounds exactly like something the system administrator may disallow.

So the question is, is there some way to create my own custom commands and
attach them to my buttons, so that wdKeyCategoryCommand may be used? Or is
there some other approach (not necessarily pretty or elegant---`working` is
the key) that could be used to attach keyboard shortcuts to my buttons while
staying away from VBA?

Thanks,

Denis.
 
X

XL-Dennis

Denis,

The following blogpost shows how we can subclassing Excel in an unmanaged
COM add-in:

http://xldennis.wordpress.com/2006/11/14/the-transition-case-com-add-in-part-ii/

For a time ago there was a thread in this newsgroup where the OP used the
same technique for Word.

I have not yet tested it with managed COM add-in.

---------------
With kind regards,
Dennis
Weekly Blog .NET & Excel: http://xldennis.wordpress.com/
My English site: http://www.excelkb.com/default.aspx
My Swedish site: http://www.xldennis.com/
 

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