VBA & Macro Problems

Identify Excel Shape Types with VBA Without Selecting Shapes

Jason MillerJason Miller Nov 18, 2026 869 views

Question details

Identify the names and types of worksheet shapes with VBA without selecting each shape.

Identify Excel Shape Types with VBA Without Selecting Shapes
Product
Microsoft Excel
Device & OS
not provided
Scenario
A user wants to inspect the shapes on a worksheet programmatically.
Observed behavior
The desired result is a list of shape properties obtained directly from the worksheet's Shapes collection.
Before you start

Open the workbook in a version of Excel that supports VBA and activate the worksheet containing the shapes. Make sure macros are enabled according to your organization's security settings.

Solution 1Recommended

Read Shape Properties from the Worksheet Shapes Collection

Loop through the active worksheet's shapes and print their properties without selecting them.

The Shape object exposes Name and Type directly. Check that a shape is an AutoShape before reading its AutoShapeType property.

1
Open the VBA editor

In Excel, open the Developer tab and select Visual Basic.

2
Add the macro

In the VBA editor, choose Insert > Module and paste: Sub ListShapeTypes() Dim shapeItem As Shape For Each shapeItem In ActiveSheet.Shapes If shapeItem.Type = msoAutoShape Then Debug.Print shapeItem.Name, shapeItem.Type, shapeItem.AutoShapeType Else Debug.Print shapeItem.Name, shapeItem.Type End If Next shapeItem End Sub

3
Run and inspect the results

Choose View > Immediate Window, place the cursor inside ListShapeTypes, and press F5. Read the names and type values in the Immediate window.

Read Shape Properties from the Worksheet Shapes Collection
Recognize a rectangle: A rectangle is generally an AutoShape whose Type equals msoAutoShape and whose AutoShapeType equals msoShapeRectangle. The Immediate window prints the underlying numeric values.
Free Microsoft Office alternative

Work with Spreadsheet Shapes in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for common Excel formats, making it easy to move everyday workbook editing between suites. Test any VBA-dependent workbook separately before relying on its macros in WPS.

View and edit worksheet shapes in WPS SpreadsheetsOpen and save common Microsoft Excel formats, including XLSX and XLSUse a familiar interface for everyday spreadsheet workMove existing workbooks into a lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Can I inspect a shape without selecting it?

Yes. Loop through ActiveSheet.Shapes and read each Shape object's Name and Type properties directly.

How can I tell whether a shape is a rectangle?

First check that shapeItem.Type equals msoAutoShape, then check whether shapeItem.AutoShapeType equals msoShapeRectangle.

Where does Debug.Print display the results?

In the VBA editor, choose View > Immediate Window. Run the macro and read the printed shape properties there.

Will this loop list shapes inside a group individually?

The worksheet Shapes collection includes the group as a shape. To inspect individual members, access the group's GroupItems collection and loop through its items.