When I run this subroutine, there is always 2 ungrouped shapes present on the sheet "Symbol Editor" so CASE 2 is always executed.
When the statement 'Selection.Name = "testThis"' Executes fine. "Set grpShapes = Selection.Group" however, when the statement: "Set grpShapes = Selection.Group" I get the following error
"Runtime error 1004 Unable to get the group Property of the DrawingObJects class" My Questions are:
- Why can I assign a value to a selection.group "property", but cannot capture the object itself?
- This question is "semi" related. Each shape has its own positioning coordinates, but once "grouped" the entire group can be "selected" and moved around a SHEET in unison. How is this done? Does the selection have its own positioning coordinate and each shape adjusts their coordinates accordingly?
'''''
Sub TestForGroups()
Dim shps As Shapes: Set shps = Sheets("Symbol Editor").Shapes
Dim grpShapes As GroupShapes
Dim TN As String
Select Case shps.Count
*Case 0
TN = TypeName(Selection)
MsgBox "There are no shapes ('" & TN & "').", vbInformation
Case 1
shps.SelectAll
TN = TypeName(Selection)
If TN = "GroupObject" Then
Selection.Ungroup
MsgBox "Ungrouped a group ('" & TN & "').", vbInformation
Else
MsgBox "One shape selected ('" & TN & "').", vbInformation
End If
Debug.Print TypeName(Selection)
Case Is > 1
shps.SelectAll
TN = TypeName(Selection)
If TypeName(Selection) = "DrawingObjects" Then
Selection.Group
MsgBox "Grouped all shapes ('" & TN & "').", vbInformation
Selection.Name = "testThis"
**Set grpShapes = Selection.Group**
End If
End Select
End Sub ''''