1

I used to use the following code:

ActivePresentation.Slides(3).Shapes("Name").TextFrame.TextRange.Text = TBN.Value

But I want to change the Shapes("Name") which is present inside a SlideLayout. How do I do that?

ActivePresentation.SlideLayout26.Shapes("Name").TextFrame.TextRange.Text = TBN.Value

The above code hasn't worked.

Thank you.

Bhavesh Shaha
  • 717
  • 5
  • 21

1 Answers1

0

Taking the link that BigBen references and making a working example ...

Option Explicit

Public Sub ModifyLayoutText()
    Dim vIndex As Integer
    vIndex = getLayoutIndexByName("Title Slide")
    If vIndex > 0 Then
        With ActivePresentation.Designs(1).SlideMaster.CustomLayouts.Item(vIndex)
            .Shapes.Item("Title 1").TextFrame2.TextRange.Text = "Simple Alt Text"
        End With
    End If
End Sub

Function getLayoutIndexByName(xName As String) As Integer
    ' Code from https://stackoverflow.com/questions/9147643/how-to-apply-particular-layout-in-powerpoint-using-vba
    Dim vCounter As Integer
    With ActivePresentation.Designs(1).SlideMaster.CustomLayouts
        For vCounter = 1 To .Count
            If .Item(vCounter).Name = xName Then
                getLayoutIndexByName = vCounter
                Exit Function
            End If
        Next
    End With
End Function
TechnoDabbler
  • 1,245
  • 1
  • 6
  • 12