将办公室主题设置为 powerpoint VBA
Set an office theme to a 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
代码在此之后继续,但这就是所有必要的。
提前致谢。
pres.ApplyTheme {您的 thmx 文件的完整路径}
查找 MS 提供的主题可能很棘手。如果您基于 Ion 主题创建一个演示文稿,将它保存为 THMX 到一个方便的位置,然后在上面的代码中指定 path/file.thmx。
会更简单
顺便说一下,您还想使用
Dim shp2 As PowerPoint.Shape
而不是
Dim shp2 As Shape
将其调暗为 Excel 形状而不是 PowerPoint 形状;它们可能具有不同的属性。
我目前正在使用 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
代码在此之后继续,但这就是所有必要的。
提前致谢。
pres.ApplyTheme {您的 thmx 文件的完整路径}
查找 MS 提供的主题可能很棘手。如果您基于 Ion 主题创建一个演示文稿,将它保存为 THMX 到一个方便的位置,然后在上面的代码中指定 path/file.thmx。
会更简单顺便说一下,您还想使用
Dim shp2 As PowerPoint.Shape
而不是
Dim shp2 As Shape
将其调暗为 Excel 形状而不是 PowerPoint 形状;它们可能具有不同的属性。