Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I programmatically close an InfoPath form in C#?

Tags:

c#

infopath

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.

like image 302
Saul Dolgin Avatar asked May 10 '26 10:05

Saul Dolgin


1 Answers

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);
        }
    }
}
like image 104
Jim Burger Avatar answered May 11 '26 22:05

Jim Burger