我以前使用以下代码:
ActivePresentation.Slides(3).Shapes("Name").TextFrame.TextRange.Text = TBN.Value
但是我想更改SlideLayout中存在的Shapes(“ Name”)。我该怎么办?
ActivePresentation.SlideLayout26.Shapes("Name").TextFrame.TextRange.Text = TBN.Value
以上代码无效。
谢谢。
答案 0 :(得分:0)
获取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