check whether shape is a group
Claude,
Handle the error:
Sub ResetSelectionV2()
For Each shp In ActiveSheet.Shapes
On Error GoTo NotGrouped
For Each grp In shp.GroupItems
If TypeOf grp.DrawingObject.Object Is MSforms.OptionButton Or _
TypeOf grp.DrawingObject.Object Is MSforms.CheckBox Then
grp.DrawingObject.Object.Value = False
End If
Next grp
NotGrouped:
Resume noErr:
noErr:
Next shp
End Sub
HTH,
Bernie
MS Excel MVP
"Claude" wrote in message
...
Hi all
I'm trying to run the following macro to reset the entries in option buttons
and check boxes.
Sub ResetSelection()
For Each shp In ActiveSheet.Shapes
For Each grp In shp.GroupItems
If TypeOf grp.DrawingObject.Object Is MSforms.OptionButton Or TypeOf
grp.DrawingObject.Object Is MSforms.CheckBox Then
grp.DrawingObject.Object.Value = False
End If
Next grp
Next shp
End Sub
This works fine for the shapes that are grouped objects, however
shp.groupitems gives an error if shp is not a group. What is the correct
syntax to perform a check on shp, e.g. something like: if shp.type =
groupedobject then...
Thanks in advance
|