1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
public void start() {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Menu bar = new Menu(shell, SWT.BAR);
shell.setMenuBar(bar);
OleFrame frame = new OleFrame(shell, SWT.NONE);
OleClientSite clientsite;
try {
clientsite = new OleClientSite(frame, SWT.NONE, "Word.Document");
shell.layout();
clientsite.doVerb(OLE.OLEIVERB_SHOW);
} catch (SWTException ex) {
System.out.println("Failed to create <> : " + ex.getMessage());
return;
}
shell.open();
while (shell != null && !shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
private void pageSetup() {
OleAutomation aut = getChildAutomation(this.wordAutomation, "PageSetup");
try {
int ids[] = aut.getIDsOfNames(new String[]{"PageWidth"});
if (aut != null) {
System.out.println(aut.getProperty(ids[0]));
aut.setProperty(ids[0], new Variant(595));
System.out.println(aut.getProperty(ids[0]));
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
URL u = new URL("http://www.smals.com");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (aut != null) {
aut.dispose();
}
}
} |
Partager