View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Jake Marx[_3_] Jake Marx[_3_] is offline
external usenet poster
 
Posts: 860
Default CombBox - Object of What Collection?

Hi George,

The OLEObject can contain many types of "objects", such as textboxes,
checkboxes, etc. So it exposes some common properties and methods, but it
can't contain all of them for each different type of object that it may hold
(some have properties/methods not found in other objects). The Object
property will return a reference to the actual object being held in the
OLEObject, which will give you access to the properties and methods specific
to that type of object (in this case, a ComboBox). Hopefully, that makes
sense - if you need clarification or have questions, please post back.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


George wrote:
Thank you, Juan for pointing that out. I didn't notice I had that
left that off as I don't really see what it is doing. However, it
finally worked as follows. I thank you and Tom, much.

Could either of you tell me why the .Object is needed after oleObj as
I thought that oleObj was referring to an Ole Object as it seems to
be identified as such and addressed as part of the OLEObjects
Collection in the For Each statement? Thus to add .Object would seem
redundant and be a reference to an object of the same object? Could
you please straighten out my thinking on this?

Dim oleObj As OLEObject, cboItem As MSForms.ComboBox

With Application.Workbooks(1).Worksheets(1)
For Each oleObj In .OLEObjects
If TypeOf oleObj.Object Is MSForms.ComboBox Then
Set cboItem = oleObj.Object
cboItem.ListIndex = -1
End If
Next oleObj
End With

Again, I thank you both for and appreciate your keen expertise for I
had tried many scenarios, but this did not occur to me.