Gets an Object for accessing the functions and global variables contained in a form's primary form code file using System.Reflection.
Assembly: Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)
'Declaration PublicMustOverrideReadOnlyPropertyExtensionAsObjectGet 'Usage DiminstanceAsXmlFormDimvalueAsObjectvalue = instance.Extension
The System.Object returned by the Extension property facilitates using the functions and global variables implemented in an InfoPath form code file. Usually, it is used from a custom task pane, from a custom dialog box, or in the XSL Transform (XSLT) of a view where direct access to the functions and variables may be needed.
To use the System.Object within a custom task pane, you must first set a reference to the XmlForm object by using the Dynamic HTML (DHTML) external property of the DHTML window object, as shown in this example.
This member can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.
This type or member can be accessed only from code running in forms opened in Microsoft InfoPath Filler.
In the following code example, the Extension property is used to return a System.Object to invoke the custom method called MyMethod.
Dim extObj As Object extObj = Me.Extension extObj.GetType().InvokeMember("MyMethod", _ BindingFlags.InvokeMethod Or _ BindingFlags.DeclaredOnly Or _ BindingFlags.Public Or _ BindingFlags.Instance, Nothing, extObj, Nothing)
In the following code example, a method called myCustomMethod of the InfoPath form code project class can be accessed from the custom task pane using the Extension property.
' Custom method added to the form code project. Function myCustomMethod() As String myCustomMethod = "Method value" End Function
To access myCustomMethod from script in the custom task pane, use the DHTML external property of the DHTML window object.