I'm working on a project that involves migrating macros in a Word Template to VB.NET making use of VSTO. We've been able to create the Word Template and migrate the code to VB.NET just fine, however we need to action a certain VSTO method from a separate .NET application.
Previously, we were able to achieve this in VBA by doing this:
Word.Application.Run(MacroName:="MyDocument.MyModule.MyMethod")
There are a few articles explaining how this can be achieved with Application and Document-level customizations, but we've yet to find any information on how this can be done with a VSTO Document-level Word Template.
We've already tried a number of different approaches including:
- Exposing the class and method as outlined in this How to expose a C# class to a VBA module in a document-level add-in?
- Introducing a VBA macro (which we can access from the .NET application), that can action the VSTO method as outlined in this MSDN article
However neither of these seems to be applicable for document-level templates. In addition to this we also tried adding a button to the ribbon which fires the required method, and attempting to access it from our .NET application using Word.Application.CommandBars.FindControl()
Some more info: the VSTO Word Template was created using VS2013, and the separate .NET application has been developed on VS2010. Both applications run .NET Framework 4.