Uncheck ActiveX Control checkbox

sassy

New Member
Joined
Feb 23, 2009
Messages
38
I am trying to uncheck all my ActiveX Control checkboxes in code at the end of my macro. I have tried several routes from the threads on this site but nothing has worked. Can anyone help??


Currently working with the following. My checkboxes are all named differently.


HTML:
If IncomeReceived.Value = True Then
    IncomeReceived.Value = False
Else
End If

and have tried ...

HTML:
'Dim sh As Shape
    For Each sh In ActiveSheet.Shapes
        'Uncheck ActiveX objects
        If sh.Type = msoOLEControlObject Then
            If TypeName(sh.OLEFormat.Object.Object) = "CheckBox" Then sh.OLEFormat.Object.Object = False
        End If
        'Uncheck Forms objects
        If sh.Type = msoFormControl Then
            If sh.FormControlType = xlCheckBox Then sh.OLEFormat.Object = False
        End If
    Next sh
End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
I'm not too sure but shouldn't this
Code:
sh.OLEFormat.Object.Object = False

be
Code:
sh.Value = False
?
 
Upvote 0
Did you try?
Code:
CheckBox1.Value = 1
CheckBox2.Value = 0
 
Upvote 0
Maybe
Code:
sh.OLEFormat.Object.Value = False

What error did you have in your original code?
 
Upvote 0
ok, it is not working with those changes. with the first code i posted, i get the object error, as well as with the suggestion from taurean (sorry!). The second code i posted just runs through and doesn't uncheck the boxes. I thought i had something declared wrong, but no matter what i change, it doesn't work.

Any other suggestions???
 
Upvote 0
see if this works for you :

Code:
Sub test()
        
    Dim oObj As OLEObject
    
    On Error Resume Next
    For Each oObj In ActiveSheet.OLEObjects
        If TypeName(oObj.Object) = "CheckBox" Then oObj.Object.Value = 0
    Next
    ActiveSheet.CheckBoxes = False

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,753
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top