StackOverflow Question

3
Question One Switch from VBA to Visual Studio Tools for Office (VSTO) Unlike VBA, where the code is stored in the document file itself, programs written with VSTO are stored in separate CLI assemblies which are associated with the documents by means of custom properties. Need to click item in MS and results in an action in the word document Use Word.Interop to communicate with word document Question Title: How to action an event in Word from another .NET application using VSTO Question Body: I’m working on a project that involves migrating a VBA macro-enabled Word document to a VSTO document-level customization. We have a .NET application which is currently able to action the Word VBA macros using Word Interop. An example line of code in our .NET application which is used to call a macro, SomeMethod, within the macro-enabled document: Word.Application.Application.Run(MacroName:="MyDoc.Module1.SomeMethod") Is there a way in which we can replicate this with the VSTO document-level customization? Question Two What we need to do: Need to call a method located within a VSTO document template from a separate application Question Title: How to run a method within a VSTO Word Template document from a separate application Question Body: We have a program which prints out the results of calculations into a styled word template document. In the past this was carried out by making use of macros. However, we’re now looking to migrate this code from VBA to .NET with VSTO. We’re currently stuck on how to action a method within the VSTO Word Template from a separate .NET application.

description

StackOverflow questions.

Transcript of StackOverflow Question

Page 1: StackOverflow Question

Question One

Switch from VBA to Visual Studio Tools for Office (VSTO) Unlike VBA, where the code is stored in the document file itself, programs written with VSTO

are stored in separate CLI assemblies which are associated with the documents by means of custom properties.

Need to click item in MS and results in an action in the word document Use Word.Interop to communicate with word document

Question Title: How to action an event in Word from another .NET application using VSTO

Question Body:

I’m working on a project that involves migrating a VBA macro-enabled Word document to a VSTO document-level customization. We have a .NET application which is currently able to action the Word VBA macros using Word Interop.

An example line of code in our .NET application which is used to call a macro, SomeMethod, within the macro-enabled document:

Word.Application.Application.Run(MacroName:="MyDoc.Module1.SomeMethod")

Is there a way in which we can replicate this with the VSTO document-level customization?

Question Two

What we need to do:

Need to call a method located within a VSTO document template from a separate application

Question Title: How to run a method within a VSTO Word Template document from a separate application

Question Body: …

We have a program which prints out the results of calculations into a styled word template document. In the past this was carried out by making use of macros. However, we’re now looking to migrate this code from VBA to .NET with VSTO. We’re currently stuck on how to action a method within the VSTO Word Template from a separate .NET application.

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.

We have a program which prints out the results of calculations into a styled word template document. In the past this was carried out by making use of macros. However, we’re now looking to migrate this code from VBA to .NET with VSTO. We’re currently stuck on how to action a method within the VSTO Word Template from a separate .NET application.

Page 2: StackOverflow Question

Question Three

Question Title: Performance issue with Word Document-Level customization

Question Body:

We have a Word Document-Level Template project that we use to automate the display of results within a Word file. We have a method in the VSTO code that reads text from a file and inserts it into the Word document, while applying formatting and styles. When this method is actioned from within the document, via a ribbon bar button, the results are displayed relatively quickly. However, when we attempt to action the code from our third party application, using a WCF service hosted by the Word document, we’re getting a massive performance hit.

We’ve attempted to identify the source of the problem using Visual Studio’s profiler. One clear difference we can see from this is that the profiler indicates that in the case of the ribbon button call the core dll that is used is wwlib.dll. When the same method is called through the WCF the profiler indicates ole32.dll as one of the core libraries and not wwlib.dll.

The profiler also tells us that in the case of the poor WCF performance code such as querying Selection.Font.Name was a bottleneck/hotspot. Whereas through the ribbon button the same code did not indicate any performance problems.