使用Excel VBA添加Powerpoint标题幻灯片 [英] Adding a Powerpoint Title slide using Excel VBA

查看:128
本文介绍了使用Excel VBA添加Powerpoint标题幻灯片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有VBA代码从excel运行,它使用从excel文档中复制的图表生成了6个幻灯片PowerPoint的演示文稿。我使用什么代码行插入标题幻灯片,并定义该幻灯片上的文本(标题+子标题)?使用Excel 2007。

解决方案

所以,@Siddharth Rout提议的一些额外的选择(这也是好的)。我使用 .AddTitle 方法,在格式化该形状的情况下可能是有益的。

  Sub add_title()

Dim shpCurrShape As Shape

Dim ppPres作为演示

设置ppPres = ActivePresentation
与ppPres.Slides(1)

如果不是.Shapes.HasTitle然后
设置shpCurrShape = .Shapes。 AddTitle
Else
设置shpCurrShape = .Shapes.Title
结束If

带有shpCurrShape
带.TextFrame.TextRange
'~~> ;在这里设置文本
.Text =BLAH BLAH
'~~>对齐
.ParagraphFormat.Alignment = 3
'~~>使用字体
With .Font
.Bold = msoTrue
.Name =Tahoma
.Size = 24
.Color = RGB(0,0,0 )
结束
结束
结束
结束
结束Sub


I have VBA code running from excel which produces a 6 slide powerpoint presentation using copied in charts from an excel document. What code lines would I use to insert a title slide, and define the text on that slide (title + sub title)? Using Excel 2007.

解决方案

So, some additional alternative for @Siddharth Rout proposal (which is good as well). I use .AddTitle method which could be beneficial in case of formatting of that shape.

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

这篇关于使用Excel VBA添加Powerpoint标题幻灯片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆