提及幻灯片布局而不是幻灯片编号的语法



我曾经使用以下代码:

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

但我想更改SlideLayout中的形状("名称"(。我该怎么做?

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

上面的代码没有工作。

谢谢。

获取BigBen引用的链接并制作一个工作示例。。。

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

最新更新