简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM