VBA & Macro Problems

Rename Excel Shapes Based on Worksheet Names Using VBA

Ayan MasoodAyan Masood Nov 3, 2026 869 views

Question details

The user needs to rename Excel shapes using a VBA macro based on worksheet or product information and generate a list of shape geometries including names, captions, positions, and dimensions.

Rename Excel Shapes Based on Worksheet Names Using VBA
Product
Excel
Device & OS
not provided
Scenario
Organizing, renaming, and extracting shape data from a worksheet using VBA for structured reporting or layout management.
Observed behavior
The macro processes shapes from left to right and row by row, requiring shapes to be perfectly aligned at the top to correctly identify rows and generate the Shape_Geometry sheet.
Before you start

Ensure you have backed up your workbook before running any VBA macros, and verify that the Developer tab is enabled so you can access the Visual Basic Editor.

Solution 1Recommended

Align Shapes and Run the Shape Geometry Macro

Properly aligning shapes ensures the VBA macro can accurately process them row by row and extract the correct geometry details.

The VBA macro processes shapes by identifying rows and moving from left to right. If the shapes are not aligned perfectly on their top edges, the macro may misinterpret the layout and process the shapes out of order.

1
Select shapes in a row

Hold down the Ctrl key or Shift key and click on each shape in a single row within your worksheet to select them together.

2
Align shapes to the top

Navigate to the 'Drawing Tools' or 'Shape Format' tab on the ribbon, click on 'Align', and select 'Align Top' so they share the exact same top position.

3
Repeat for all rows

Perform the same alignment process for every row of shapes in your workbook to ensure uniformity across the sheet.

4
Run the VBA macro

Open your VBA Editor (Alt + F11), review the code comments, and run the CreateShapeGeometryList macro to rename shapes and generate the Shape_Geometry sheet.

Align Shapes and Run the Shape Geometry Macro
Alignment Check: By keeping the top position identical, the macro's row-detection logic works flawlessly to correctly log names, captions, positions, widths, and heights.
Advanced Spreadsheet Management

Manage Shapes and Macros Seamlessly with WPS Spreadsheet

WPS Office provides robust support for VBA macros, allowing you to easily rename shapes, manage worksheet objects, and automate complex tasks just like in Microsoft Excel.

  1. 1. Open your macro workbook: Launch WPS Spreadsheet and open your existing macro-enabled workbook (.xlsm).
  2. 2. Enable the Developer tab: Navigate to the settings to enable the Developer tab, giving you full access to the VBA editor and macro controls.
  3. 3. Align your shapes: Use the built-in 'Drawing Tools' under the 'Page Layout' or 'Insert' tab to align your worksheet shapes precisely.
  4. 4. Execute your VBA code: Click 'Macros' on the Developer tab, select your shape renaming and geometry extraction script, and click Run.
Fully compatible with Microsoft Excel (.xlsx, .xlsm) macro-enabled formats.Built-in VBA editor to seamlessly write, edit, and execute shape management scripts.Advanced shape alignment and formatting tools easily accessible from the intuitive ribbon interface.Lightweight architecture ensuring fast performance even when processing shape-heavy workbooks.
microsoft office alternative - wps office

Frequently Asked Questions

Why are my shapes being processed out of order by the VBA macro?

This usually happens if the top edges of the shapes are not perfectly aligned. The macro relies on the top-position coordinates to determine rows. Use the 'Align Top' tool under Drawing Tools to fix this before executing the script.

What kind of data does the shape geometry macro extract?

A standard shape geometry macro is designed to read and log the shape's specific name, caption text, top position, left position, width, and height, compiling them into a new sheet (often called Shape_Geometry) for easy reference.

How do I access the VBA editor to review the macro code?

You can open the Visual Basic Editor by pressing Alt + F11 on your keyboard. Ensure you have the Developer tab enabled in your ribbon settings to access the full suite of macro tools.

Can I run Excel VBA shape macros in WPS Office?

Yes, WPS Office supports VBA in its macro-enabled versions. You can open your .xlsm files and run your existing Excel macros directly to rename shapes and extract geometry.