WorksheetBase.OLEObjects Method
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)
Syntax
'Declaration
Public Function OLEObjects ( _
index As Object _
) As Object
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.
Remarks
Optional Parameters
For information on optional parameters, see 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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.