Worksheet.OLEObjects Method (2007 System)

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.

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

Syntax

'Declaration
Public Function OLEObjects ( _
    Index As Object _
) As Object
'Usage
Dim instance As Worksheet 
Dim Index As Object 
Dim returnValue As Object 

returnValue = instance.OLEObjects(Index)
public Object OLEObjects(
    Object Index
)
public:
Object^ OLEObjects(
    Object^ Index
)
public function OLEObjects(
    Index : Object
) : Object

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 OLEObject) or a collection of all OLE objects (an OLEObjects collection) on the worksheet.

Remarks

Optional Parameters

For information on optional parameters, see The Variable missing and Optional Parameters in Office Solutions.

Examples

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 Sub DisplayOLEObjectsCount()
    Dim oleObjects1 As Excel.OLEObjects = _
        CType(Me.OLEObjects(), Excel.OLEObjects)
    MsgBox("There are " & oleObjects1.Count & " OLE objects in " & _
        "this worksheet.")
End Sub
private void DisplayOLEObjectsCount()
{
    Excel.OLEObjects oleObjects1 = (Excel.OLEObjects)this.OLEObjects(missing);
    MessageBox.Show("There are " + oleObjects1.Count + " OLE objects in " +
        "this worksheet.");
}

.NET Framework Security

See Also

Reference

Worksheet Class

Worksheet Members

Microsoft.Office.Tools.Excel Namespace