InfoPath's ActiveX - InfoPath Dev
in

InfoPath Dev

InfoPath's ActiveX

Last post 06-05-2007 09:37 AM by davidair. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 06-04-2007 01:01 AM

    • romaik
    • Top 500 Contributor
    • Joined on 05-31-2007
    • Paris France
    • Posts 43

    InfoPath's ActiveX

    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 ?
     

    InfoPath 2003 SP2 User
  • 06-04-2007 03:32 PM In reply to

    I am no Java expert but I think you might be using a wrong control...

    "InfoPath.Application" is used for external script automation and does not represent an OLE server, that is why you would be getting error  -2147221164 (aka 0x80040154 = REGDB_E_CLASSNOTREG).

    I only know how to host an Infopath editing environment in C#: http://msdn2.microsoft.com/en-us/library/aa701079.aspx

    However, I looked up the CLSID of that component and it seems like it's ProgId is "InfoPath.Editor.2" so you could maybe give it a shot. Good luck!

    David Airapetyan / Software Services Architect
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 06-05-2007 12:14 AM In reply to

    • romaik
    • Top 500 Contributor
    • Joined on 05-31-2007
    • Paris France
    • Posts 43

    Thanks (again :p )

    But it still doesn't work with InfoPath.Editor.2 (maybe because I am using InfoPath 2003). Moreover, I can't find it in Registry Editor (regedit).

    I guess this might be also a Java problem (incorrect source code)

     

    Still, my quest for the answer continues. I'll let you know if I succeed.

     

    PS : I found an alternative : Infoscope which allow me to display a InfoPath form into my Web Browser (Internet Explorer 6 basically) but it is complicating the process because now I have to work with html too ; and it does not support everything in InfoPath.

    InfoPath 2003 SP2 User
  • 06-05-2007 09:37 AM In reply to

    Oh wait, of course, you cannot host InfoPath 2003! You can only do external automation with it.

    Hosting of InfoPath in another application was only introduced with InfoPath 2007, sorry :(

     

    David Airapetyan / Software Services Architect
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.