Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT MS Word Save Button
SWT MS Word Save Button [message #660183] Thu, 17 March 2011 09:30 Go to next message
Hans Dampf is currently offline Hans DampfFriend
Messages: 2
Registered: March 2011
Junior Member
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! Wink

[Updated on: Thu, 17 March 2011 14:29]

Report message to a moderator

Re: SWT MS Word Save Button [message #661220 is a reply to message #660183] Wed, 23 March 2011 15:47 Go to previous messageGo to next message
Felipe Heidrich is currently offline Felipe HeidrichFriend
Messages: 29
Registered: July 2009
Junior Member
I would expect this menu item to be enabled.

Try using OleFrame#setFileMenus

(sorry but I can't test your code because I do not have office 2010)
Re: SWT MS Word Save Button [message #661311 is a reply to message #660183] Thu, 24 March 2011 07:46 Go to previous messageGo to next message
Hans Dampf is currently offline Hans DampfFriend
Messages: 2
Registered: March 2011
Junior Member
But i do not have a FileItem MenuItem, because the save button is an item of Word

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:) )
Re: SWT MS Word Save Button [message #1006553 is a reply to message #661311] Thu, 31 January 2013 17:04 Go to previous message
Alexandre Borgoltz is currently offline Alexandre BorgoltzFriend
Messages: 14
Registered: July 2009
Location: France
Junior Member
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!
Previous Topic:snippet of context menu in a Mozilla Browser not work with swt 4.2 and xulrunner 10
Next Topic:Print functionality in Linux
Goto Forum:
  


Current Time: Sat Nov 29 04:11:00 GMT 2014

Powered by FUDForum. Page generated in 0.02848 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software