我有从 excel 运行的 VBA 代码,它使用从 excel 文档中复制的图表生成 6 张幻灯片演示文稿。我将使用哪些代码行来插入标题幻灯片并定义该幻灯片上的文本(标题 + 副标题)?使用 Excel 2007。
最佳答案
因此,@Siddharth Rout 提案的一些额外替代方案(这也很好)。我用 .AddTitle
在格式化该形状的情况下可能是有益的方法。
Sub add_title()
Dim shpCurrShape As Shape
Dim ppPres As Presentation
Set ppPres = ActivePresentation
With ppPres.Slides(1)
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 = 3
'~~> Working with font
With .Font
.Bold = msoTrue
.Name = "Tahoma"
.Size = 24
.Color = RGB(0, 0, 0)
End With
End With
End With
End With
End Sub
关于vba - 使用 Excel VBA 添加 Powerpoint 标题幻灯片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15709996/