I have searched thoroughly through the Internet and the Stackoverflow site without success. I've been stuck in a problem for a week and I cannot make heads or tails of it.
I have been studying VBA and my reference book is giving the following example:
Private Sub CommandButtons()
Dim intcounter As Integer, xObj As OLEObject
Dim strObj As String
intcounter = 0
strObj = ""
For Each xObj In ActiveSheet.OLEObjects
If TypeName(xObj.Object) = "Check Box" Then
If xObj.Object.Value = True Then
intcounter = intcounter + 1
strObj = strObj & xObj.Object.Caption & Chr(10)
End If
End If
Next xObj
If intcounter = 0 Then
MsgBox _
"There were no CheckBoxes selected", ,
Else
MsgBox _
"you selected" & intcounter & "checkboxes:" _
& vbCrLf & vbCrLf & _
strObj, , "Here is what you checked"
End If
End Sub
Unfortunately this code does not work. It is supposed to evaluate every embedded boject on the worksheet. When the code comes across an ActiveX CheckBox, it should determine whether the CheckBox is checked. At the end of the procedure, a MsgBox will appear, confirming how many (if any) CheckBox were checked and their caption.
Can anybody help me with this? Even a link would be more than welcome.
Thank you in advance for your assistance.
Aucun commentaire:
Enregistrer un commentaire