0

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:

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.

Community
  • 1
  • 1
nelb
  • 15
  • 1
  • 4

1 Answers1

0

You can use standard .Net mechanisms such as WCF (.Net Remoting) and etc. Consider your document level add-in as a separate application.

In case of application level add-ins, you can call them directly. See Calling Code in Application-Level Add-ins from Other Office Solutions for more information.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • We've looked at the application-level customization, however it doesn't apply to our project as we're working with document-level customization. We have some knowledge of WCF as we use it to communicate with some Windows hosted services. Could you elaborate on how WCF could be used to call a VSTO method from another .NET application? – nelb Feb 25 '15 at 17:12
  • Yes, the link I mentioned can't be applied to document-level customizations. Use .Net remoting for communication between your applications. You may consider your document-level add-in as a regular .net application. – Eugene Astafiev Feb 25 '15 at 17:20