0

I am currently trying to do a replace all on the object name in PowerPoint. Normally each content object is named Content Placeholder #, I have already named each object something like "PptBobChart1, PptBobScatter1", and now I need to do a replace all to change each of the object names into "PptTomChart1, PptTomScatter1". I know I can go into the selection pane one at a time to manually change it, but is there a way to do the whole thing in VBA?

2 Answers 2

0

You could try something like:

Sub renameObj()
    Dim o As Shape
    Dim s As Slide
    For Each s In ActivePresentation.Slides
        For Each o In s.Shapes
            o.Name = Replace(o.Name, "Bob", "Tom")
        Next o
    Next s
End Sub

Hope this Helps!

Sign up to request clarification or add additional context in comments.

Comments

0

If you want to set different names for different01DEC2015 object types, you can use this:

Option Explicit

' ============================================================
' PowerPoint Macro : RenameOnSlideObjects
' ============================================================
' Purpose : Renames all on-slide objects within a presentation
' Inputs : Noe
' Outputs : None
' Dependencies : None
' Author : Jamie Garroch of http://youpresent.co.uk/
' Date : 01 December 2015
' ============================================================
Public Sub RenameOnSlideObjects()
  Dim oSld As Slide
  Dim oShp As Shape
  For Each oSld In ActivePresentation.Slides
    For Each oShp In oSld.Shapes
      With oShp
        Select Case True
          Case .Type = msoPlaceholder ' you could then check the placeholder type too
            .Name = "myPlaceholder"
          Case .Type = msoTextBox
            .Name = "myTextBox"
          Case .Type = msoAutoShape
            .Name = "myShape"
          Case .Type = msoChart
            .Name = "myChart"
          Case .Type = msoTable
            .Name = "myTable"
          Case .Type = msoPicture
            .Name = "myPicture"
          Case .Type = msoSmartArt
            .Name = "mySmartArt"
          Case .Type = msoGroup ' you could then cycle though each shape in the group
            .Name = "myGroup"
         Case Else
            .Name = "Unspecified Object"
        End Select
      End With
    Next
  Next
End Sub

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.