WorksheetBase.OLEObjects(Object) 方法

定義

取得表示工作表上一個 OLE 物件 (OLEObject) 或所有 OLE 物件集合 (OLEObjects) 的物件。Gets an object that represents either a single OLE object (an OLEObject) or a collection of all OLE objects (an OLEObjects collection) on the worksheet.

public object OLEObjects (object index);

參數

index
Object

OLE 物件的名稱或編號。The name or number of the OLE object.

傳回

Object

表示工作表上一個 OLE 物件 (OLEObject) 或所有 OLE 物件集合 (OLEObjects) 的物件。An object that represents either a single OLE object (an OLEObject) or a collection of all OLE objects (an OLEObjects collection) on the worksheet.

範例

下列程式碼範例會使用 OLEObjects 方法來顯示目前工作表中的 OLE 物件數目。The following code example uses the OLEObjects method to display the number of OLE objects in the current worksheet.

這個範例適用于檔層級自訂。This example is for a document-level customization.

private void DisplayOLEObjectsCount()
{
    Excel.OLEObjects oleObjects1 = (Excel.OLEObjects)this.OLEObjects();
    MessageBox.Show("There are " + oleObjects1.Count + " OLE objects in " +
        "this worksheet.");
}
Private Sub DisplayOLEObjectsCount()
    Dim oleObjects1 As Excel.OLEObjects = _
        CType(Me.OLEObjects(), Excel.OLEObjects)
    MsgBox("There are " & oleObjects1.Count & " OLE objects in " & _
        "this worksheet.")
End Sub

備註

選擇性參數Optional Parameters

如需選擇性參數的詳細資訊,請參閱Office 方案中的選擇性參數For information on optional parameters, see Optional Parameters in Office Solutions.

適用於