共用方式為


TaskPaneObject 介面

代表與視窗關聯的 Microsoft Office InfoPath 表單中的工作窗格。

**命名空間:**Microsoft.Office.Interop.InfoPath
**組件:**Microsoft.Office.Interop.InfoPath (於 microsoft.office.interop.infopath.dll 中)

語法

'宣告
<GuidAttribute("096CD58E-0786-11D1-95FA-0080C78EE3BB")> _
<CoClassAttribute(GetType(TaskPaneObjectClass))> _
Public Interface TaskPaneObject
    Inherits TaskPane
'用途
Dim instance As TaskPaneObject
[GuidAttribute("096CD58E-0786-11D1-95FA-0080C78EE3BB")] 
[CoClassAttribute(typeof(TaskPaneObjectClass))] 
public interface TaskPaneObject : TaskPane

備註

此類型為 coclass 的包裝函式,屬於 COM 互通性中 Managed 程式碼的必要項。使用此類型,即可存取由此 coclass 實作的 COM 介面成員。如需 COM 介面 (包括其成員說明連結) 的詳細資訊,請參閱 TaskPane

TaskPaneObject 物件提供使用 InfoPath 內建工作窗格的屬性。而 HTMLTaskPaneObject 物件則繼承這些使用自訂工作窗格的屬性。

InfoPath 工作窗格可用的屬性是由正在使用的工作窗格類型決定。如果 TaskPaneType 屬性傳回 0,則工作窗格為自訂工作窗格,而可用的屬性及方法由 HTMLTaskPane 物件提供。如果 TaskPaneType 屬性傳回任何其他值,則工作窗格為內建工作窗格,而屬性由 TaskPaneObject 物件提供。

注意

TaskPaneType 是以 XdTaskPaneType 列舉為基礎,這些列舉值也會做為 TaskPanesCollection 集合的 Item 屬性引數使用,以傳回指定工作窗格類型的參考。

範例

在下列範例中,使用 TaskPanesCollection 集合的 Item 屬性,取得代表自訂工作窗格的 TaskPane 物件參照。接著程式碼會呼叫在自訂工作窗格的 HTML 程式碼中定義的指令碼函數,該工作窗格使用 HTMLTaskPaneObject 物件 (由 TaskPane 物件繼承) 的 HTMLDocument 屬性。

// Ensure View has loaded before trying to access the task pane.
if (thisXDocument.View != null)
{
 // Get a reference to the custom task pane.  It is always the 0-th
 // task pane in the TaskPanes collection.
 HTMLTaskPane custom = (HTMLTaskPane) thisXDocument.View.Window.TaskPanes[0];

 // Ensure that the task pane is completely loaded.
 if (custom != null && custom.HTMLDocument.readyState == "complete")
 {
  mshtml.IHTMLWindow2 window = custom.HTMLDocument.parentWindow;

  object[] args =  new object[] {"ViewID"};

  // call into script through CLR late binding mechanism
  window.GetType().InvokeMember(
   "SelectView",      // 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
   args);
 }
}

注意

上述範例需要 Microsoft.mshtml.dll 組件的參考。

請參閱

參考

TaskPaneObject 成員
Microsoft.Office.Interop.InfoPath 命名空間