Application.RegisterFormTemplate Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| RegisterFormTemplate(String) |
Installs the specified form template. |
| RegisterFormTemplate(String, String) |
Installs the specified form template with the option to overwrite the previous registration record for the form template. |
RegisterFormTemplate(String)
Installs the specified form template.
public:
abstract void RegisterFormTemplate(System::String ^ formTemplateLocation);
public abstract void RegisterFormTemplate(string formTemplateLocation);
abstract member RegisterFormTemplate : string -> unit
Public MustOverride Sub RegisterFormTemplate (formTemplateLocation As String)
Parameters
- formTemplateLocation
- 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.
Exceptions
The form template file cannot be found.
The parameter passed to this method is a null reference (Nothing in Visual Basic).
The parameter passed to this method is not valid. For example, it is of the wrong type or format.
Remarks
If the form template has already been registered, the form template's registration record will be overwritten. To control whether a previously registered form template's record is overwritten, use the RegisterFormTemplate(String, String) method instead.
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.
Applies to
RegisterFormTemplate(String, String)
Installs the specified form template with the option to overwrite the previous registration record for the form template.
public:
abstract void RegisterFormTemplate(System::String ^ formTemplateLocation, System::String ^ behavior);
public abstract void RegisterFormTemplate(string formTemplateLocation, string behavior);
abstract member RegisterFormTemplate : string * string -> unit
Public MustOverride Sub RegisterFormTemplate (formTemplateLocation As String, behavior As String)
Parameters
- formTemplateLocation
- 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
- 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
The form template file cannot be found.
The parameters passed to this method are a null reference (Nothing in Visual Basic).
The parameters passed to this method are not valid. For example, they are of the wrong type or format.
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
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.