How to deploy C # code and VBA scripts in one Word VSTO add-on

The main problem I was trying to solve was to apply special key bindings for the internal methods of adding VSTO Word (with the C # extension):

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 is no way (in the object model or Word application) to bind to everything except VBA macros."

Other developers are trying to implement a workaround using the VBA method, which assigns key bindings to VBA callbacks when loading addin and calls C # addin from these callbacks in turn. (see calling VBA with C # for details)

This idea has a chance for life: .NET AddIn and Word template with VBA support. But in my project, I need to deliver this add-on in one Click Once package to destination computers (inside the corporate network, where security settings are not a problem).

So the question is: how to make a combination of C # add-on (Ribbon) and VBA scripts in a single deployment package?

Does anyone have such an experience?

+7
c # vba vsto clickonce
source share
3 answers

And here we go!

Walkthrough Deploying multiple office solutions in a single ClickOnce installer for the .NET Framework 3.5.

A lot of handmade. But the idea of ​​updating the ClickOnce package with additional dependencies (edit XML manifest). The standard ClickOnce installer will do everything for you.

+1
source share

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

0
source share

I asked your ClickOnce product team my question. He said that you can include scripts in your VSTO deployment, and you can follow the deployment steps with the VSTO add-in if you plan to use .NET 4.0. He said that you can also do this through the VBA Interop features in VSTO. Are you targeting .NET 4.0?

0
source share

All Articles