HOW DO I PROGRAMMATICALLY CLOSE AN INFOPATH FORM IN C#?

Goti Bandu

Total Post:119

Points:835
Posted by  Goti Bandu
C# 
C#
 2649  View(s)
Ratings:
Rate this:
Is it possible to close an InfoPath form programmatically? I know that it can be configured as a form rule action but I want to close the form via code
  1. ezra heywood

    Post:145

    Points:1019
    Re: How do I programmatically close an InfoPath form in C#?

    Hi Goti,

    Use the ApplicationClass.XDocuments.Close method and pass it your document object:

    using System;

    using Microsoft.Office.Interop.InfoPath;

    namespace ConsoleApplication1

    {

        class Program

        {

            static void Main(string[] args)

            {

                var app = new ApplicationClass();

                var uri = @".\form1.xml";

                var doc = app.XDocuments.Open(uri, 0);

                app.XDocuments.Close(doc);

            }

        }

    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!