Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsSWT MS Word Save Button
https://www.eclipse.org/forums/index.php/mv/msg/206219/660183/#msg_660183
I'm trying to use MS Word 2010 in a SWT-Application. I can open a File but the Save-Button of Word is not enabled.
With an additional Button, wich executes the save-Method of the OleClientSite saves the document.
Display display = new Display();
final Shell shell = new Shell(display);
shell.setSize(600, 400);
shell.setText("WordTest");
shell.setLayout(new FillLayout(SWT.VERTICAL));
final File f = new File("C:\\test.pptx");
OleFrame oleFrame = new OleFrame(shell, SWT.NONE);
final OleClientSite site = new OleClientSite(oleFrame, SWT.NONE, f);
site.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent arg0) {
System.out.println("Disposed");
}
});
shell.layout();
site.doVerb(OLE.OLEIVERB_SHOW);
Menu bar = new Menu(shell, SWT.BAR);
shell.setMenuBar(bar);
MenuItem file = new MenuItem(bar, SWT.CASCADE);
file.setText("&File");
Menu sub = new Menu (shell, SWT.DROP_DOWN);
file.setMenu (sub);
MenuItem item = new MenuItem (sub, SWT.PUSH);
item.setText("&Save");
item.addListener (SWT.Selection, new Listener () {
public void handleEvent (Event e) {
site.save(f, false);
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
Please help me!
]]>Hans Dampf2011-03-17T09:30:50-00:00Re: SWT MS Word Save Button
https://www.eclipse.org/forums/index.php/mv/msg/206219/661220/#msg_661220
Try using OleFrame#setFileMenus
(sorry but I can't test your code because I do not have office 2010) ]]>Felipe Heidrich2011-03-23T15:47:20-00:00Re: SWT MS Word Save Button
https://www.eclipse.org/forums/index.php/mv/msg/206219/661311/#msg_661311
I think it has something to do with the OleClientSite, because it "contains" the Word application.
I tried to use the method exec like this:
site.exec(OLE.OLECMDID_SAVEAS, OLE.OLECMDEXECOPT_DODEFAULT, null, null);
I get an error from Word that says, that the storage process can't be completed because of a file permission error.
(Please ignore me bad english:) )]]>Hans Dampf2011-03-24T07:46:43-00:00Re: SWT MS Word Save Button
https://www.eclipse.org/forums/index.php/mv/msg/206219/1006553/#msg_1006553
I am facing the same problem : When embedding MSWord2010 with an OleClientSite, the save button in the "ribbon" is disabled. And trying to invoke the document's Save methode does nothing (with error message :
The Save method or property is not available because this document is in another application
If I use an OleControlSite, it does work but the document is opened outside of my swt app, as a standalone window...
Have you found out what's wrong?
Thanks in advance!]]>Alexandre Borgoltz2013-01-31T17:04:31-00:00