Search code examples
pluginsswtole

How to open Word Application using SWT OLE?


I need to open the word application using swt ole but not in the shell rather i want open it externally i.e. as a separate application. Please Help me. I'm a student and not well versed in swt ole(If possible,please provide me the code). Thanks in advance!


Solution

  • Try below sample code:

    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();
    }