1

Sheet "Symbol Editor" is the only sheet in the workbook.**

        Sub AssembleSymbol()    
            Worksheets("Symbol Editor").Shapes.SelectAll
            Selection.Group
        End Sub

Before the subroutine AssembleSymbol() is run, there are 3 shapes inserted into the Symbol Editor, then the subroutine is run and I get:

"Excel Runtime Error 438 Object does not support property or method"

Even though I get an error, when you look at the worksheet all shapes are selected and grouped.

The rationale for grouping the Shapes is to save the shapes as 1 collective symbol along with their "relative" positions, to one another, in a "SymbolLibrary" to be used in future, user-defined, "displays"

Any help would be appreciated.

1 Answer 1

3

TypeName With Shapes

  • Most likely the shapes were grouped already when this error would occur.
Sub AssembleSymbolOrig()
    Worksheets("Symbol Editor").Shapes.SelectAll
    MsgBox TypeName(Selection), vbInformation, "TypeName"
    If TypeName(Selection) = "DrawingObjects" Then Selection.Group
End Sub

Sub AssembleSymbolStudy()
    
    Dim wb As Workbook: Set wb = ThisWorkbook
    Dim ws As Worksheet: Set ws = wb.Worksheets("Symbol Editor")
    Dim shps As Shapes: Set shps = ws.Shapes
    
    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
    Case Is > 1
        shps.SelectAll
        TN = TypeName(Selection)
        If TN = "DrawingObjects" Then
            Selection.Group
            MsgBox "Grouped all shapes ('" & TN & "').", vbInformation
        End If
    End Select
    
End Sub
Sign up to request clarification or add additional context in comments.

1 Comment

thank you for your answers. Microsoft used to publish a large poster of the Excel object Model, for reference. does anyone have any idea where I might find this on the internet?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.