使用VBA插入PowerPoint标题的循环10幻灯片
我在Stackoverflow中看到了此代码,该代码将标题插入一个幻灯片。
Sub add_title()
Dim shpCurrShape As Shape
Dim ppPres As Presentation
Set ppPres = ActivePresentation
With ActivePresentation.Slides.Range(Array(1, 2, 3, 4, 5))
If Not .Shapes.HasTitle Then
Set shpCurrShape = .Shapes.AddTitle
Else
Set shpCurrShape = .Shapes.Title
End If
With shpCurrShape
With .TextFrame.TextRange
'~~> Set text here
.Text = "BLAH BLAH"
'~~> Alignment
.ParagraphFormat.Alignment = 1
'~~> Working with font
With .Font
.Bold = msoTrue
.Name = "Tw Cen MT"
.Size = 24
.Color = RGB(0, 0, 0)
End With
End With
End With
End With
End Sub
我想为给定数量的幻灯片添加相同的幻灯片标题,例如前十幅幻灯片。
我知道可以通过循环进行选择,从而选择感兴趣的幻灯片范围。
另外,如何定义阵列以指示幻灯片20至30?
I saw this code in StackOverflow that inserts a title in one slide.
Sub add_title()
Dim shpCurrShape As Shape
Dim ppPres As Presentation
Set ppPres = ActivePresentation
With ActivePresentation.Slides.Range(Array(1, 2, 3, 4, 5))
If Not .Shapes.HasTitle Then
Set shpCurrShape = .Shapes.AddTitle
Else
Set shpCurrShape = .Shapes.Title
End If
With shpCurrShape
With .TextFrame.TextRange
'~~> Set text here
.Text = "BLAH BLAH"
'~~> Alignment
.ParagraphFormat.Alignment = 1
'~~> Working with font
With .Font
.Bold = msoTrue
.Name = "Tw Cen MT"
.Size = 24
.Color = RGB(0, 0, 0)
End With
End With
End With
End With
End Sub
I would like to add the same slide title for a given number of slides, for example, the first ten slides.
I understand it can be done with a loop, selecting the range of the slides of interest.
Also, how would I define the array for indicating slides 20 to 30?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将把幻灯片更改为其他子的决定,然后将
add_title
仅转到您希望更改的幻灯片。I would move the decision over which slides to change to a different sub, then call
add_title
only to those slides you wish to change.