vba - 使用 Excel VBA 添加 Powerpoint 标题幻灯片

标签 vba excel

我有从 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/

相关文章:

excel - 按范围查找

excel - 在 Excel 中对数字立方体维度进行排序

python - 如何将词典列表输出到 Excel 工作表?

excel - 将复制/粘贴限制为仅用于不更改条件格式的值

vba - MS Access : eval() returns NULL when accessing . 列(x,y)属性

vba - 类模块函数中的错误处理

arrays - 对数组的特定列进行计算

excel - 需要使用 Excel 宏将 H、K、L 列从一个 Excel 工作簿复制到新工作簿

excel - 定义工作簿名称时,VBA类型不匹配

vba - 删除powerpoint中的表格边框