Quantcast
Channel: NetOffice - MS Office in .NET
Viewing all articles
Browse latest Browse all 1741

Commented Unassigned: How can I initialize NetOffice.WordApi objects using a Microsoft.Office.Interop objects? [22069]

$
0
0
I have a Microsoft Office Addin Project on Visual Studio. It uses Microsoft.Office.Interop.dll . Within the code logic, I need to use NetOffice.WordApi instead of the regular Interop assemblies. My question is this: Since NetOffice is a wrapper to Microsoft.Office.Interop.dll , How can I initialize a NetOffice.WordApi objects using a Microsoft.Office.Interop objects (e.g. Application -> Application , INDocument -> NODocument or Table to Table)
Comments: ** Comment from web user: SebastianDotNet **

In NetOffice 1.7.3 you have to use the ctor from the corresponding wrapper class.
The following examples used a non-existing method called "CreateObject" which is the same like the VB6 well-known method to create a new COM class trough late-binding.

example1 - Word Application

object interopProxy = CreateObject("Word.Application");
NetOffice.WordApi.Application app = new NetOffice.WordApi.Application(null, interopProxy);

example2 - Word Document
object interopProxy = CreateObject("Word.Document);
NetOffice.WordApi.Document document = new NetOffice.WordApi.Document(null, interopProxy);

may nice to know:
I've been created some static methods in NetOffice 1.7.4 to do this easier because its a common problem for beginners. Its something like:

var managedNetOfficeWrapper = COMObject.CreateInstanceFromProxy(interopProxy);
// netoffice analyze the proxy and creates the corresponding wrapper automaticaly - you have to cast the result from the common base class COMObject to its actual type.

moreover: as far i remember, the NO 1.7.3 includes a tutorial how to face this challenge. you may give'em a try ;) ( i know, the most open-source projects doesnt spend a good explanation/documentation. I alyways try to do this better like a commercial/professional project. Its need the same time as the development - please do me pleasure and spend 5-10 minutes for the tutorials)

"The tutorials are sufficient to understand what makes NetOffice tick. Great info!"
- a customer feedback from a United States company

*Sebastian



Viewing all articles
Browse latest Browse all 1741

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>