Opening Form using C# code - InfoPath Dev
in

InfoPath Dev

Opening Form using C# code

Last post 01-23-2007 10:03 PM by lyntonS. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 01-22-2007 02:52 AM

    • lyntonS
    • Not Ranked
    • Joined on 01-09-2007
    • South Africa
    • Posts 12

    Opening Form using C# code

    Please can someone help me with the following. How do you open a form using the FormCode.cs page and the 'Rule and Custom Code' action under the button properties window? Is is possible to pass a form a parameter from another form?
  • 01-22-2007 05:19 AM In reply to

    Re: Opening Form using C# code

    Hi,
    NewFormSolutionMethod is used to create an InfoPath form from a form template
    ex: objIP.NewFromSolution ("C:\My Forms\MyFormTemplate.xsn")

    Apply a Rule on Button
    Steps to follow:
    1. Click on Rules button in Button Propeties dialog box
    2. Click on Add button in Rules dialog box
    3. Click on Add Action button in Rule dialog box
    4. Select Open a new form to fill out in Action drop down
    5. Enter the path from where the form is to be opened in Form Id or Location
    6. Click on Ok button 4 times to close all dialog boxes

    Check this link to pass parameter from another form
    http://infopathdev.com/forums/topic.asp?TOPIC_ID=36

    Hope this helps you!
    Shilpa
    INFOPATHDEV India
  • 01-23-2007 10:03 PM In reply to

    • lyntonS
    • Not Ranked
    • Joined on 01-09-2007
    • South Africa
    • Posts 12

    Re: Opening Form using C# code

    Thanks for the help. Thus far I have the code as follows. I am working with C# and InfoPath 2007:

    [InfoPathEventHandler(MatchPath = "btnSubmit", EventType = InfoPathEventType.OnClick)]
    public void btnSubmit_OnClick(DocActionEvent e)
    {

    IXMLDOMProcessingInstruction oXML = thisXDocument.DOM.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");
    IXMLDOMProcessingInstruction oPI = thisXDocument.DOM.createProcessingInstruction("mso-application", "progid=\"InfoPath.Document\"");
    thisXDocument.DOM.insertBefore((IXMLDOMNode)oPI, thisXDocument.DOM.firstChild);
    thisXDocument.DOM.insertBefore((IXMLDOMNode)oXML, thisXDocument.DOM.firstChild);

    // Open a solution from a XML DOM
    // Create a new DOM
    IXMLDOMDocument newDoc = thisXDocument.CreateDOM();

    string myXml = "<txtInput></txtInput>";
    newDoc.loadXML(myXml);


    // Call NewSolutionWithData to open a new Form and load the XML
    XDocument oXdpostingForm = thisApplication.XDocuments.NewFromSolution(@"C:\Program Files\bSOLVe_LS_Publish\PassingParameters.xsn");
    XDocument oXdreceivingForm = thisApplication.XDocuments.NewFromSolutionWithData
    ("C:\\Program Files\\bSOLVe_LS_Publish\\Source_ParametersReceived\\template.xml",
    @"C:\Program Files\bSOLVe_LS_Publish\ParametersReceived.xsn",
    (int)XdDocumentVersionMode.xdFailOnVersionOlder);

    To continue with the problem - I design the form in one folder and publish and install it in another form. I get the following exception though?

    InfoPath cannot create a new, blank form.
    The system cannot find the path specified.

    at Microsoft.Office.Interop.InfoPath.SemiTrust.XDocumentsCollectionWrapper.NewFromSolutionWithData
    (Object varXMLData, Object varSolutionURI, Int32 dwBehavior)

    PLEASE HELP!


Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.