首页 > 解决方案 > 将 office 主题设置为 powerpoint VBA

问题描述

我目前正在使用 vba 从 excel 制作一个自动 Powerpoint,我想为文档设置一个主题,准确地说是“Ion”主题。我有以下代码:

Sub CreateFullPres()

Dim ppt As PowerPoint.Application
Dim pres As PowerPoint.Presentation
Dim sld As PowerPoint.Slide
Dim shp2 As Shape


'Create Powerpoint
Set ppt = New PowerPoint.Application
Set pres = ppt.Presentations.Add
ppt.Visible = True


'Add Slide
Set Slide1 = pres.Slides.Add(1, ppLayoutTitle).Shapes.Placeholders
SlideTitle = Sheets("FIBO Monthly Update").Range("B4")
SubTitle1 = Sheets("FIBO Monthly Update").Range("B6")
SubTitle2 = Sheets("FIBO Monthly Update").Range("B7")
Slide1.Item(1).TextFrame.TextRange.Text = SlideTitle
Slide1.Item(2).TextFrame.TextRange.Text = SubTitle1 & ": " & SubTitle2

代码在此之后继续,但这就是所有必要的。

提前致谢。

标签: vbathemespowerpoint

解决方案


pres.ApplyTheme {thmx 文件的完整路径}

查找 MS 提供的主题可能很棘手。如果您基于 Ion 主题创建演示文稿,将其作为 THMX 保存到方便的位置,然后在上面的代码中指定 path/file.thmx,会更简单。

顺便说一句,您还想使用

Dim shp2 As PowerPoint.Shape

代替

Dim shp2 As Shape

将其变暗为 Excel 形状而不是 PowerPoint 形状;它们可能具有不同的属性。


推荐阅读