Share via


Application.RegisterFormTemplate Method (String, String)

Installs the specified form template with the option to overwrite the previous registration record for the form template.

Namespace:  Microsoft.Office.InfoPath
Assembly:  Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)

Syntax

'Declaration
Public MustOverride Sub RegisterFormTemplate ( _
    formTemplateLocation As String, _
    behavior As String _
)
'Usage
Dim instance As Application
Dim formTemplateLocation As String
Dim behavior As String

instance.RegisterFormTemplate(formTemplateLocation, _
    behavior)
public abstract void RegisterFormTemplate(
    string formTemplateLocation,
    string behavior
)

Parameters

  • formTemplateLocation
    Type: System.String

    Specifies the Uniform Resource Locator (URL) of the form template. This parameter can be specified as a form definition (.xsf) file or a form template (.xsn) file.

  • behavior
    Type: System.String

    Specifies how the form template is to be installed. The default value is "overwrite". The only other valid value for this parameter is "new-only".

Exceptions

Exception Condition
FileNotFoundException

The form template file cannot be found.

ArgumentNullException

The parameters passed to this method are a null reference (Nothing in Visual Basic).

ArgumentException

The parameters passed to this method are not valid. For example, they are of the wrong type or format.

Remarks

If the form template has already been registered, and "new-only" is specified for the behavior parameter, the RegisterFormTemplate method will return an error. If "overwrite" is specified, the form template's registration record will be overwritten.

This member can be accessed only by forms opened from a form template that has been configured to run with full trust using the Security and Trust category of the Form Options dialog box. This member requires full trust for the immediate caller and cannot be used by partially trusted code. For more information, see "Using Libraries from Partially Trusted Code" on MSDN.

This type or member can be accessed only from code running in forms opened in Microsoft InfoPath Filler.

Examples

In the following example, the RegisterFormTemplate method of the Application class is used in a function to install a form template. The example assumes that there is a using or Imports statement for the Microsoft.Office.InfoPath namespace in the declarations section of the class that contains the function, and that the Microsoft InfoPath 3.0 Type Library is referenced on the COM tab of the Add Reference dialog box in Visual Studio.

public void InstallForm()
{
Microsoft.Office.InfoPath.Application infoPathApp = 
   new Microsoft.Office.InfoPath.Application();
infoPathApp.RegisterFormTemplate(@"C:\My Forms\MyFormTemplate.xsn", 
   "overwrite");
}
Public Sub InstallForm()
Dim infoPathApp As Microsoft.Office.InfoPath.Application = _
   new Microsoft.Office.InfoPath.Application()
infoPathApp.RegisterFormTemplate("C:\My Forms\MyFormTemplate.xsn", _
   "overwrite")
End Sub

Permissions

See Also

Reference

Application Class

Application Members

RegisterFormTemplate Overload

Microsoft.Office.InfoPath Namespace