WorksheetBase.OLEObjects Method (Object)

 

Gets an object that represents either a single OLE object (an Microsoft.Office.Interop.Excel.OLEObject) or a collection of all OLE objects (an Microsoft.Office.Interop.Excel.OLEObjects collection) on the worksheet.

Namespace:   Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

public object OLEObjects(
	object index
)

Parameters

index
Type: System.Object

The name or number of the OLE object.

Return Value

Type: System.Object

An object that represents either a single OLE object (an Microsoft.Office.Interop.Excel.OLEObject) or a collection of all OLE objects (an Microsoft.Office.Interop.Excel.OLEObjects collection) on the worksheet.

For information on optional parameters, see Optional Parameters in Office Solutions.

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.");
}
Return to top
Show: