[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [platform-swt-dev] Accessing MS Word from SWT
|
You need to trigger the file save code from somewhere, currently it is only
running once just after the shell opens.
Adding a save item to the file menu is described in:
http://www.eclipse.org/articles/Article-ActiveX%20Support%20in%20SWT/ActiveX%20Support%20in%20SWT.html
See the section entitled "Create the OLE Object".
|---------+---------------------------------->
| | "Sivakumar Ekambaram" |
| | <sivanayak@xxxxxxxxxxx>|
| | Sent by: |
| | platform-swt-dev-admin@|
| | eclipse.org |
| | |
| | |
| | 19/11/2002 01:23 PM |
| | Please respond to |
| | platform-swt-dev |
| | |
|---------+---------------------------------->
>-----------------------------------------------------------------------------------------------------------------|
| |
| To: platform-swt-dev@xxxxxxxxxxx |
| cc: |
| Subject: [platform-swt-dev] Accessing MS Word from SWT |
>-----------------------------------------------------------------------------------------------------------------|
Hi
I am trying to access MS word document from SWT, want to do some
modifications programatically and save the document. Please look into the
below code and let me know what i am missing to do the needed one.
And also i need to display menu bar in the ole container which displays the
word document so that i could provide an interface for the user to save the
document.
int i;
Display display = new Display();
Shell shell = new Shell(display);
swtTest t = new swtTest();
OleFrame frame = new OleFrame(shell, SWT.NONE);
frame.setLayoutData(new GridData(GridData.FILL_BOTH));
Menu bar = new Menu(shell, SWT.BAR);
shell.setMenuBar(bar);
shell.setLayout(new GridLayout());
File file = new File("C:\\Source\\Name.doc");
OleClientSite clientSite = new
OleClientSite(frame,SWT.NONE,file);
OleAutomation oleAutomation = new OleAutomation(clientSite);
clientSite.setEnabled(true);
clientSite.setVisible(true);
frame.setVisible(true);
clientSite.setSize(900, 900);
i = clientSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
frame.setSize(1000,1000);
if(i == OLE.S_OK) {
System.out.println("OK");
}
shell.open();
shell.setSize(1001, 1001);
if (clientSite.isDirty()) {
File tempFile = new File(file.getAbsolutePath() +
".tmp");
file.renameTo(tempFile);
if (clientSite.save(file, true)){
// save was successful so discard the
backup
tempFile.delete();
} else {
// save failed so restore the backup
tempFile.renameTo(file);
}
}
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) {
display.sleep ();
}
}
display.dispose ();
}
Thanks
_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev