_ExternalApplication2.New(String, Int32) 方法

定义

基于指定的表单创建新表单。

public:
 void New(System::String ^ bstrDocumentURI, int dwBehavior);
public void New (string bstrDocumentURI, int dwBehavior);
abstract member New : string * int -> unit
Public Sub New (bstrDocumentURI As String, dwBehavior As Integer)

参数

bstrDocumentURI
String

字符串值,指定表单的统一资源标识符 (URI)。

dwBehavior
Int32

默认值为 1。 指定打开表单的方式。 这些值基于 XdDocumentVersionMode 枚举。

实现

示例

在以下示例(用 C# 编程语言编写)中,对象的 New 方法 ExternalApplication 用于基于指定的窗体创建新窗体:

private void CreateFromForm()
{
 ExternalApplication infoPath = new ExternalApplicationClass();

 // Create an InfoPath form.
 infoPath.<span class="label">New</span>(@"C:\My Forms\Form1.xml", 1);
}

注意:上述示例假定 Microsoft.Office.Interop.InfoPath 正在使用命名空间,并且引用了 Microsoft InfoPath 3.0 类型库。

在以下示例(用 C# 编程语言编写)中,对象的 New 方法 ExternalApplication 用于基于指定的窗体创建新窗体:

private void CreateFromForm()
{
 ExternalApplication infoPath = new ExternalApplicationClass();

 // Create an InfoPath form.
 infoPath.<span class="label">New</span>(@"C:\My Forms\Form1.xml", 1);
}

注意:上述示例假定 Microsoft.Office.Interop.InfoPath 正在使用命名空间,并且引用了 Microsoft InfoPath 3.0 类型库。

注解

New 方法只能基于现有表单来新建表单,而不能基于表单模板来新建表单。 若要从表单模板创建表单,请使用 NewFromSolution(String) 方法。

使用 New 方法时,InfoPath 处于打开状态,可随时填写新表单。

注意 不能使用 Close(String) 关闭已使用 New 方法打开的窗体。 当 New 方法创建某个表单时,该表单的名称未知。

重要说明:此成员只能由已配置为使用“表单选项”对话框的“安全与信任”类别以完全信任方式运行的表单模板打开的表单访问。 此成员要求直接调用方的完全信任并且不能由部分信任的代码使用。 有关更多信息,请参阅 MSDN 上的“使用部分信任的代码中的库”。

适用于