views:

403

answers:

3

Underlying problem I was trying to solve is to apply custom key bindings for internal VSTO Word addin methods (develiped in C#):

Globals.ThisAddIn.Application.KeyBindings.Add(  
    Word.WdKeyCategory.wdKeyCategoryCommand,  
    "MyMethodName",  
    myKey,
    ref _missing,  
    ref _missing);

Well, the problem is that this code always throws an exception because (Microsoft MSDN): “there's no way (in the object model or Word application) to bind to anything but VBA macros”.

What other developers are trying to do is to implement a workaround with VBA method that assign key bindings to VBA callbacks when addin loads, and call C# addin from those callbacks in turn. (see how to call VBA from C# for details)

This idea has a chance for live: .NET AddIn and VBA-enabled Word template. But in my project I need to deliver this addin in a single Click Once package to end-user machines (inside a corporate network where security settings are not an issue).

So the Question is: how to make a mix of C# Add-In (Ribbon) and VBA scripts in one deployment package?

Does anyone has such experience to share?

+1  A: 

And here we go!

Walkthrough: Deploying Multiple Office Solutions in a Single ClickOnce Installer for the .NET Framework 3.5.

A lot of hand work. But the idea is to update ClickOnce package with additional dependencies (edit manifest XML). Standard ClickOnce setup program will do the rest for you.

Ghen
Good find Ghen. You can go ahead and accept your own answer (the check mark thingy) so that this thread shows as "answered".
Otaku
your link has passed away.
m_oLogin
A: 

hmmm seems like a workaround when you can just use windows subclassing to bind directly to a keyboard shortcut.

Anonymous Type
A: 

I asked the ClickOnce product team your question. He said you can include the scripts in the VSTO deployment, and you can do post-deployment steps with a VSTO add-in if you are targeting .NET 4.0. He said you might also be able to do this through VBA Interop features in VSTO. Do you happen to be targeting .NET 4.0?

RobinDotNet