Edit

Share via


HTMLTaskPane.HTMLDocument Property

Definition

Gets a reference to an HTML document object of the Microsoft Office InfoPath 2003 custom task pane.

public:
 property mshtml::IHTMLDocument2 ^ HTMLDocument { mshtml::IHTMLDocument2 ^ get(); };
public mshtml.IHTMLDocument2 HTMLDocument { get; }
member this.HTMLDocument : mshtml.IHTMLDocument2
Public ReadOnly Property HTMLDocument As IHTMLDocument2

Property Value

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.<span class="label">HTMLDocument</span>;
  // 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.<span class="label">HTMLDocument</span>.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);

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.

Applies to