SWT MS Word Save Button [message #660183] |
Thu, 17 March 2011 05:30  |
Eclipse User |
|
|
|
Hello,
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.
Here is my Code:
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
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!
[Updated on: Thu, 17 March 2011 10:29] by Moderator
|
|
|
|
|
Re: SWT MS Word Save Button [message #1006553 is a reply to message #661311] |
Thu, 31 January 2013 12:04  |
Eclipse User |
|
|
|
Hi,
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!
|
|
|
Powered by
FUDForum. Page generated in 0.04082 seconds