Forum Discussion
keldsor
Oct 27, 2022Copper Contributor
Finding type of graphic objects WITHOUT selecting ???
I have a sheet with some rectangles, arrows and triangles.
Each rectangle has a number as it's Name and when I want to add new rectangles I need to find the biggest 'number' Name allready used and count further from there.
This code run through the shapes and can find out the types - but it seems I have to SELECT the object and that not good for another pert of the project.
Can it be done WITHOUT selecting the shape - this is just to show my problem - no need to make it more sofisticated than that - KISS you know :
Sub IdentifyShapes() Dim s As Shape For Each s In ActiveSheet.Shapes s.Select Debug.Print s.Type, TypeName(Selection) Next s End Sub
You could use
Sub IdentifyShapes() Dim s As Shape For Each s In ActiveSheet.Shapes Debug.Print s.Name, s.Type, s.AutoShapeType Next s End Sub
For a rectangle, s.Type will be 1 = msoAutoShape, and s.AutoShapeType will be 1 = msoShapeRectangle
2 Replies
Sort By
You could use
Sub IdentifyShapes() Dim s As Shape For Each s In ActiveSheet.Shapes Debug.Print s.Name, s.Type, s.AutoShapeType Next s End Sub
For a rectangle, s.Type will be 1 = msoAutoShape, and s.AutoShapeType will be 1 = msoShapeRectangle
- keldsorCopper ContributorOK, then I'll have to check for BOTH Type and AutoShapeType (both = 1) for a Ractangle
THX for your time !