Automating InfoPath

R

rahul

I am trying to automate Infopath through c#. Through this external code i am
able to launch Infopath application and change the data.

The only thing which I am not able to do is capture the save submit or close
event. My requirement is to get the xml data stored in the infopath form
when the user is done with editing.

The code piece is:

myApp = new Microsoft.Office.Interop.InfoPath.Application();

InfoPath.XDocument myXDoc = myApp.XDocuments.Open(@"C:\Documents and
Settings\raverma\Desktop\test2.xml",
(int)InfoPath.XdDocumentVersionMode.xdFailOnVersionOlder);

InfoPath._XDocument2 x2 = myXDoc as InfoPath._XDocument2;


//myXDoc.OnSubmitRequest += new
InfoPath._XDocumentEventSink2_OnSubmitRequestEventHandler(myXDoc_OnSubmitRequest);

//myXDoc.OnSaveRequest += new
Microsoft.Office.Interop.InfoPath._XDocumentEventSink2_OnSaveRequestEventHandler(myXDoc_OnSaveRequest);

//myXDoc.OnLoad += new
Microsoft.Office.Interop.InfoPath._XDocumentEventSink2_OnLoadEventHandler(myXDoc_OnLoad);

//InfoPathXml.IXMLDOMDocument2 domo = myXDoc.CreateDOM() as
InfoPathXml.IXMLDOMDocument2;
 
J

Josh

To submit a form using the InfoPath submit function. Use
this.thisDocument.Subit();

That will submit the form as if you hit the submit at the top of the
page. I put this on a button, on the form.

Josh
 
R

rpost

rahul said:
I am trying to automate Infopath through c#. Through this external code i am
able to launch Infopath application and change the data.

The only thing which I am not able to do is capture the save submit or close
event. My requirement is to get the xml data stored in the infopath form
when the user is done with editing.

I am trying to do exactly the same thing, and from the complete lack
of documentation I'm tempted to conclude that this isn't possible at all.

Not even if the code you're quoting is itself part of form handling code
within an InfoPath solution!
InfoPath.XDocument myXDoc = myApp.XDocuments.Open(@"C:\Documents and
Settings\raverma\Desktop\test2.xml",
(int)InfoPath.XdDocumentVersionMode.xdFailOnVersionOlder);

InfoPath._XDocument2 x2 = myXDoc as InfoPath._XDocument2;

//myXDoc.OnSubmitRequest += new
InfoPath._XDocumentEventSink2_OnSubmitRequestEventHandler(myXDoc_OnSubmitRequest);

[...]

The commented line would work if XDocument or XDocument2 did in fact
have an OnSubmitRequest event, but that is not what the object model says
(it doesn't declare any events on an XDocument, or for that matter,
on any other class of InfoPath object).

Form handling code within an InfoPath form does get the OnSubmitRequest
event thrown at it from somewhere, but, as far as I can tell, only for the
form that was already open, not for any forms that the code opens itself.

This is driving me up the wall, so please prove me wrong ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top