Hello
I am trying to launch the InfoPath's ActiveX control from a Java application but it does not work.
Using InfoPath.Application as ProgId, I get this message :
Exception in thread "main" org.eclipse.swt.SWTException: Failed to create Ole Client. result = -2147221164
at org.eclipse.swt.ole.win32.OLE.error(OLE.java:302)
at org.eclipse.swt.ole.win32.OleClientSite.<init>(OleClientSite.java:241)
at Main.exemple(Main.java:48)
at Main.main(Main.java:75)
Using InfoPath.Document.1 as ProgId, Iget this message :
Exception in thread "main" org.eclipse.swt.SWTException: Class ID not found in registry result = -2147221005
at org.eclipse.swt.ole.win32.OLE.error(OLE.java:317)
at org.eclipse.swt.ole.win32.OleClientSite.getClassID(OleClientSite.java:652)
at org.eclipse.swt.ole.win32.OleClientSite.<init>(OleClientSite.java:230)
at Main.exemple(Main.java:48)
at Main.main(Main.java:75)
My class that tries to launch the ActiveX
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.ole.win32.OLE;
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class Main {
/**
* @param args
*/
// composants de l’interface graphique de base
private Display display = null;
private Shell shell = null;
private Composite compo = null;
// Initialisation des composants de base
public Main() {
display = new Display();
Display.setAppName("Techis_OLE");
shell = new Shell(display);
shell.setLayout(new FillLayout());
compo = new Composite(shell, SWT.NORMAL);
compo.setLayout(new GridLayout());
GridData grid = new GridData(GridData.FILL_BOTH);
grid.widthHint = 600;
grid.heightHint = 600;
compo.setLayoutData(grid);
}
// Insertion des functions d’exemple
public void exemple() {
OleFrame frame = new OleFrame(compo, SWT.BORDER);
frame.setLayout(new GridLayout());
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.widthHint = 500;
gridData.heightHint = 500;
frame.setLayoutData(gridData);
OleClientSite clientSite = new OleClientSite(frame, SWT.NONE,
"InfoPath.Document.1");
try {
clientSite.doVerb(OLE.OLEIVERB_SHOW);
clientSite.forceFocus();
} catch (Exception e) {
e.printStackTrace();
}
}
//
public void run() {
shell.open();
shell.setActive();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
public static void main(String[] args) {
Main m = new Main();
m.exemple();
m.run();
}
}
Any idea on how to make it work ?