Class OLEObject (Excel VBA)

The class OLEObject represents an ActiveX control or a linked or embedded OLE object on a worksheet.


Dim oleob as OLEObject
Set oleob = ActiveChart.OLEObjects(Index:=1)

For Each

Here is an example of processing the OLEObject items in a collection.


Worksheets("Sheet1").Activate 
Range("A1").Value = "Name" 
Range("B1").Value = "Link Status" 
Range("C1").Value = "AutoUpdate Status" 
i = 2 
For Each obj In ActiveSheet.OLEObjects 
 Cells(i, 1) = obj.Name 
 If obj.OLEType = xlOLELink Then 
 Cells(i, 2) = "Linked" 
 Cells(i, 3) = obj.AutoUpdate 
 Else 
 Cells(i, 2) = "Embedded" 
 End If 
 i = i + 1 
Next

Methods

Activate - Activates the object.

BringToFront - Brings the object to the front of the z-order.

Copy - Copies the object to the Clipboard.

CopyPicture - Copies the selected object to the Clipboard as a picture.

Cut - Cuts the object to the Clipboard or pastes it into a specified destination.

Delete - Deletes the object.

Duplicate - Duplicates the object and returns a reference to the new copy.

Select - Selects the object.

SendToBack - Sends the object to the back of the z-order.

Update - Updates the link.

Verb - Sends a verb to the server of the specified OLE string.

Properties

AutoLoad true if the OLE object is automatically loaded when the workbook that contains it is opened.

AutoUpdate true if the OLE object is updated automatically when the source changes. Valid only if the object is linked; its OLEType property must be xlOLELink (XlOLEType enumeration).

Border returns a Border object that represents the border of the object.

BottomRightCell returns a Range object that represents the cell that lies under the lower-right corner of the object.

Enabled true if the object is enabled.

Height returns or sets a Double value that represents the height, in points, of the object.

Index returns a Long value that represents the index number of the object within the collection of similar objects.

Interior returns an Interior object that represents the interior of the specified object.

Left returns or sets a Double value that represents the distance, in points, from the left edge of the object to the left edge of column A (on a worksheet) or the left edge of the chart area (on a chart).

LinkedCell returns or sets the worksheet range linked to the control's value. If you place a value in the cell, the control takes this value. Likewise, if you change the value of the control, that value is also placed in the cell.

ListFillRange returns or sets the worksheet range used to fill the specified list box. Setting this property destroys any existing list in the list box.

Locked returns or sets a Boolean value that indicates if the object is locked.

Name returns or sets a String value representing the name of the object.

Object returns the OLE Automation object associated with this OLE object. Read-only object.

OLEType returns the OLE xloletype type. Can be one of the following XlOLEType constants: xlOLELink or xlOLEEmbed. Returns xlOLELink if the xloletype is linked (it exists outside of the file), or returns xlOLEEmbed if the xloletype is embedded (it's entirely contained within the file). Read-only Long.

Placement returns or sets a Variant value containing an XlPlacement constant that represents the way the xlplacement is attached to the cells below it.

PrintObject true if the object is printed when the document is printed.

progID returns the programmatic identifiers for the object.

Shadow returns or sets a Boolean value that determines if the object has a shadow.

ShapeRange returns a ShapeRange object that represents the specified object or objects.

SourceName returns or sets a String value that represents the specified object's link source name.

Top returns or sets a Double value that represents the distance, in points, from the top edge of the object to the top of row 1 (on a worksheet) or the top of the chart area (on a chart).

TopLeftCell returns a Range object that represents the cell that lies under the upper-left corner of the specified object.

Visible returns or sets a Boolean value that determines whether the object is visible.

Width returns or sets a Double value that represents the width, in points, of the object.

ZOrder returns the z-order position of the object.

Border - Represents the border of an object.

Interior - Represents the interior of an object.

Range - Represents a cell, a row, a column, a selection of cells containing one or more contiguous blocks of cells, or a 3D range.

ShapeRange - Represents a shape range, which is a set of shapes on a document.