Home > DeveloperSection > Forums > How do I programmatically close an InfoPath form in C#?
Goti Bandu

Total Post:119

Posted on    November-14-2013 3:11 AM

 C# C# 

 1 Reply(s)
 2535  View(s)
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

ezra heywood
ezra heywood

Total Post:145

Posted on    November-14-2013 4:55 AM

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);





Don't want to miss updates? Please click the below button!

Follow MindStick