Renaming Objects in PowerPoint

后端 未结 3 2022
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-05 11:28

Probably a very stupid question but I can\'t figure how to rename an object in PowerPoint.. For example, all my Graphs are called by default \"Graph 1\" etc. Could someone help

3条回答
  •  借酒劲吻你
    2021-02-05 11:58

    (This answer assumes you are merely assigning more meaningful names during development, so your other code that references the objects can be more readable).

    Put the code below into a sub, then run it from the slide in question. Each shape will be selected in turn, so you can see what shape is being referenced. An input box will tell you the current name and ask you for a new name. If you cancel or OK a zero-length input, the old name will stay in place. There is no name entry validation in this code, so be sure you type only valid names. After running it once, you can run it again just to check that the names you typed in the first round were applied to the object you intended.

    The loop will cover all objects on the current slide, so if you want to process multiple slides, you have to run this separately on each slide. Every object on the slide is considered: title, drawing objects, groups, embedded pictures, equations, etc. etc. - just don't type a new name for objects that you don't care.

    After your development is finished, best hide (Private Sub) or erase this code, so your users don't change object names by mistake.

    Dim s As Integer, NewName As String
    
    With ActiveWindow.Selection.SlideRange
        For s = 1 To .Shapes.Count
            .Shapes(s).Select ' So you can see the object in question
            NewName = InputBox(.Shapes(s).Name) ' Tell what current name it is and ask for new name
            If Len(NewName) > 0 Then .Shapes(s).Name = NewName ' If you typed a new name, apply it
        Next s ' 1 To .Shapes.Count
    End With ' ActiveWindow.Selection.SlideRange
    

提交回复
热议问题