VBA Macro: Rename a Shape Name

Last updated on April 29th, 2024

Sometimes, you need to rename a shape object from the default name to any desired name, especially if you will deal with VBA code in the future and want to use more descriptive names for shapes and objects. This snippet will help you rename objects easily using a Macro.

To use it, just create a new Module using the developer tools and VBA. Then, when you need to rename an object or shape, select the shape and run the macro. You will be asked to enter a new shape.

' You can use this snippet Macro in PowerPoint to rename shapes and objects
' Select the shape in the slide where you want to rename the object and then
' run the macro to rename it. Alternatively you can use the Visibility Panel

Sub RenameShape()
    Dim objName
    On Error GoTo CheckErrors
    If ActiveWindow.Selection.ShapeRange.Count = 0 Then
        MsgBox "You need to select a shape first"
        Exit Sub
    End If
    objName = ActiveWindow.Selection.ShapeRange(1).Name
    objName = InputBox$("Assing a new name to this shape", "Rename Shape", objName)
    If objName <> "" Then
        ActiveWindow.Selection.ShapeRange(1).Name = objName
    End If

    Exit Sub

CheckErrors:
    MsgBox Err.Description

End Sub

Alternatively, you may want to use the Selection Pane in order to reorder and rename shapes and object.

renaming shapes powerpoint

Then you can enter the new name.

VBA Macro: Rename a Shape Name

This method should be enough to rename your shapes and objects in Microsoft PowerPoint.

Leave a Comment

Your email address will not be published. Required fields are marked *