View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Leith Ross
 
Posts: n/a
Default Syntax to return the value of a control by reference


Hello Broadband Al,

As you have found out working with ActiveX (Control Toolbox) objects
isn't intuitively obvious. Hopefully these examples will make things
clearer.

Clearing/Setting ActiveX Controls:

Dim MyObj As Object
Dim Obj
For Each Obj In ActiveSheet.OLEOBjects
If Obj.ProgID = "Forms.CheckBox.1" Then
Set MyObj = Obj
MyObj.Value = False
End If
Next Obj

These can be used for OptionButtons also. Change Obj.ProgID to
Obj.PorgID = "Forms.OptionButton.1".

To set the value instead of clearing it, change MyObj.Value = False to
MyObj.Value = True.

Clearing a ComboBoxes:

Dim MyObj As Object
Dim Obj

For Each Obj In ActiveSheet.OLEObjects
If Obj.ProgID = "Forms.ComboBox.1" Then
Set MyObj = Obj
MyObj.Clear
End If
Next Obj

If you have any further questions, you can contact me by email at
.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile:
http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=505139