如何使用 SWT OLE 打开 Word 应用程序?

How to open Word Application using SWT OLE?

我需要使用 swt ole 打开 word 应用程序而不是在 shell 中,而是我想在外部打开它,即作为一个单独的应用程序。 请帮我。 我是一名学生,不太精通 swt ole(如果可能,请提供代码)。 提前致谢!

试试下面的示例代码:

try {
     Shell shell = new Shell(Display.getDefault());
     Composite displayArea = new Composite(shell, SWT.BORDER);
     displayArea.setLayout(new FillLayout());
     OleFrame oleFrame = new OleFrame(displayArea, SWT.NONE);
     OleClientSite clientSite = new OleClientSite(oleFrame, SWT.NONE, "Word.Document", new File(fileName));
} catch (SWTException error) {
     error.printStackTrace();
}