【问题标题】:OLE: embed microsoft word without add insOLE:在没有插件的情况下嵌入 microsoft word
【发布时间】:2015-06-04 09:43:50
【问题描述】:

Start Word without Add Ins 所述,可以在没有“加载项”或“安全模式”的情况下启动 ms 字。
我想知道这是否也可以在我的 SWT 应用程序中使用 OLE 嵌入单词?

现在我执行以下操作:

new OleControlSite(clientFrame, SWT.NONE, "Word.Document")

也许还有另一个程序 id,类似于“Word.Document”,它强制 word 在没有插件的情况下启动?
也许有一个属性或设置可以做到这一点?

【问题讨论】:

    标签: java ms-word swt ole


    【解决方案1】:

    这个代码,在eclipse论坛里,加载word后禁用加载项:
    https://www.eclipse.org/forums/index.php/t/221747/

    int idAddIns = application.getIDsOfNames(new String[] {"COMAddIns"})[0];
    Variant addInsVar = application.getProperty(idAddIns);
    OleAutomation addIns = addInsVar.getAutomation();
    
    int countID = addIns.getIDsOfNames(new String[] {"Count"})[0];
    Variant countVariant = addIns.getProperty(countID);
    
    int addInsItemID = addIns.getIDsOfNames(new String[] {"Item"})[0];
    for (int i = 1; i <= countVariant.getInt(); i++) {
        Variant addInsItemVariant = addIns.invoke(addInsItemID, new Variant[] {new Variant(i)});
        OleAutomation addInsItem = addInsItemVariant.getAutomation();
    
        int addInsItemConnectID = addInsItem.getIDsOfNames(new String[] { "Connect" })[0];
        if (addInsItem.getProperty(addInsItemConnectID).getBoolean()) {
            int addInsItemNameID = addInsItem.getIDsOfNames(new String[] { "ProgId" })[0];
            Variant addInsItemNameVariant = addInsItem.getProperty(addInsItemNameID);
            String name = addInsItemNameVariant.getString();                
            addInsItem.setProperty(addInsItemConnectID, new Variant(false));
        }
    }
    

    警告:它还会禁用应用程序外部的加载项,因此您可能希望在关闭应用程序后启用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-25
      • 2012-01-14
      • 1970-01-01
      • 2017-08-26
      • 2016-04-15
      • 2012-09-02
      • 2016-02-19
      • 2018-05-24
      相关资源
      最近更新 更多