Java-将C#OneNote连接转换为Java Jacob

时间:2018-11-12 08:49:59

标签: java c# jacob

此页面描述了如何与Microsoft OneNotehttps://docs.microsoft.com/en-us/office/client-developer/onenote/application-interface-onenote

进行交互

我想使用C# Code Example将此JACOB转换为Java:

static void GetEntireHierarchy()
    {
        String strXML;
        OneNote.Application onApplication = new OneNote.Application();
        onApplication.GetHierarchy(null, 
            OneNote.HierarchyScope.hsPages, out strXML);
        Clipboard.SetText(strXML);
        MessageBox.Show("The XML has been copied to the clipboard");
    }

我不确定如何在Java中实现通过引用传递的字符串?

这是我目前的做法:

String[] myArray = new String[] {""}
ActiveXComponent oneNote = new ActiveXComponent("OneNote.Application")
Dispatch dispatch = Dispatch.call(oneNote, "GetHierarchy", new Object[] {null, "OneNote.HierarchyScope.hsPages", myArray}).toDispatch()

但是我得到了这个例外:

Caused by: com.jacob.com.ComFailException: Can't map name to dispid:
GetHierarchy    at com.jacob.com.Dispatch.invokev(Native Method)    at
com.jacob.com.Dispatch.invokev(Dispatch.java:625)   at
com.jacob.com.Dispatch.callN(Dispatch.java:453)     at
com.jacob.com.Dispatch.call(Dispatch.java:541)

有什么主意吗?

0 个答案:

没有答案