HTMLTaskPane.HTMLDocument Property
Gets a reference to an HTML document object of the Microsoft InfoPath 2010 custom task pane.
Namespace: Microsoft.Office.Interop.InfoPath.SemiTrust
Assembly: Microsoft.Office.Interop.InfoPath.SemiTrust (in Microsoft.Office.Interop.InfoPath.SemiTrust.dll)
Syntax
'Declaration
ReadOnly Property HTMLDocument As IHTMLDocument2
Get
'Usage
Dim instance As HTMLTaskPane
Dim value As IHTMLDocument2
value = instance.HTMLDocument
IHTMLDocument2 HTMLDocument { get; }
Property Value
Type: IHTMLDocument2
Remarks
The HTMLDocument property of the HTMLTaskPaneObject object is one of the properties inherited by the TaskPaneObject object when the type of the task pane is 0, which means that it is the custom task pane.
Using the HTMLDocument property, you can call scripting functions contained in the HTML code of the task pane through late binding, as in the second example below. You can also directly manipulate the HTML code of the task pane using any of the properties and methods that the HTML document object provides.
Note
Before using the HTMLDocument property of the HTMLTaskPaneObject object, you must first cast the TaskPaneObject object to an HTMLTaskPane object as shown in the examples below.
Important
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.
Examples
In the following example, the HTMLDocument property of the HTMLTaskPane object is used to set a reference to the HTML window object of the custom task pane of a fully trusted form. Then the code changes the background color of the custom task pane.
Note
The following examples require a reference to the Microsoft.mshtml.dll assembly.
using mshtml;
public void ChangeBackgroundColor()
{
// Get a reference to the custom task pane. It is always index [0] in the TaskPanes collection.
HTMLTaskPane oTaskPane = (HTMLTaskPane)thisXDocument.View.Window.TaskPanes[0];
// Get a reference to the HTML document object of the custom task pane.
IHTMLDocument2 oHTMLDoc = oTaskPane.HTMLDocument;
// Change custom task pane background color to red.
oHTMLDoc.bgColor = "red";
}
In the following example, the HTMLDocument property of the HTMLTaskPane object is used to set a reference to the HTML window object of the custom task pane of a fully trusted form. Then the code calls the TaskPaneSwitchView custom function that is defined in the HTML code of the custom task pane.
HTMLTaskPane custom = (HTMLTaskPane) thisXDocument.View.Window.TaskPanes[0];
mshtml.IHTMLWindow2 window = custom.HTMLDocument.parentWindow;
// call into script through CLR late binding mechanism
custom.HTMLDocument.parentWindow.GetType().InvokeMember(
"TaskPaneSwitchView", // late bound method
System.Reflection.BindingFlags.InvokeMethod | // binding flags
System.Reflection.BindingFlags.DeclaredOnly |
System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance,
null, // binder object
window, // target object
null);