0

I'm trying to run through a huge PowerPoint file and I want to change certain TextBoxes fonts on each slide (not every slide has the textbox) however I keep getting an error when it can't be found on a slide (which is fine I just want it to skip to the next slide and check and change if necessary) How would I fix this please?

Sub ChangeIndividualFonts()

    Dim bpFontName As String

    bpFontName = "Arial"

    With ActivePresentation
        For Each Slide In .Slides
            For Each Shape In Slide.Shapes
                With Slide.Shapes("TextBox 5")
                    If .HasTextFrame Then
                        If .TextFrame.HasText Then
                            .TextFrame.TextRange.Font.Name = bpFontName
                        End If
                    End If
                End With
            Next
        Next
    End With

End Sub
braX
  • 11,506
  • 5
  • 20
  • 33
Jay Hayers
  • 47
  • 8
  • First step - get rid of the `For Each Shape in Slide.Shapes` loop – BigBen Feb 25 '20 at 17:20
  • Does this answer your question? [Existence of shapes in Powerpoint](https://stackoverflow.com/questions/48343425/existence-of-shapes-in-powerpoint) – BigBen Feb 25 '20 at 17:24
  • See my reply elsewhere re changing text size/font/etc. Build on the code I provided there and in this case, look at each shape, do If oSh.Name="TextBox 5" Then to eliminate shapes with other names. – Steve Rindsberg Feb 28 '20 at 17:07

0 Answers0