vba - 将 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
代码在此之后继续,但这就是所有必要的。
提前致谢。
解决方案
pres.ApplyTheme {thmx 文件的完整路径}
查找 MS 提供的主题可能很棘手。如果您基于 Ion 主题创建演示文稿,将其作为 THMX 保存到方便的位置,然后在上面的代码中指定 path/file.thmx,会更简单。
顺便说一句,您还想使用
Dim shp2 As PowerPoint.Shape
代替
Dim shp2 As Shape
将其变暗为 Excel 形状而不是 PowerPoint 形状;它们可能具有不同的属性。
推荐阅读
- django - 如何使用 Django 中的用户凭据登录?
- ruby - Ruby 程序无法在终端中正确显示
- sql - 不使用子查询或显式联接的查询
- ios - ChildViewController/View 无法通过 GMSMapView 获得焦点
- python - 通过应用 SymPy 函数计算数组的值会导致 AttributeError
- amazon-s3 - 通知 S3 对象已创建后,无法从 S3 下载文件到 lambda
- pipe - 是否有两个不同的进程试图执行管道指令段?
- c# - 在写入期间锁定 Azure Blob
- facebook - 脸书ID错误
- spring-boot - 了解长生不老药