0

我在 Visual Studio 上有一个 Microsoft Office 插件项目。它使用 Microsoft.Office.Interop.dll 。在代码逻辑中,我需要使用 NetOffice.WordApi 而不是常规的 Interop 程序集。我的问题是:由于 NetOffice 是 Microsoft.Office.Interop.dll 的包装器,我如何使用 Microsoft.Office.Interop 对象(例如 Application -> Application 、 INDocument -> NODocument 或 Table 来初始化 NetOffice.WordApi 对象桌子)

4

1 回答 1

1

NetOffice 中的每个类都有一个构造函数,允许您包装现有的__ComObject

public Application(COMObject parentObject, object comProxy) : base(parentObject, comProxy)
{
    // ...
}

第一个参数需要一个父 NetOffice COMObject(你没有),所以通过null,第二个是你的__ComObject.

因此:

var wrappedApp = new Application(null, yourInteropObject);
于 2015-12-10T05:00:05.203 回答