vba - 用于更改 Powerpoint 演示文稿中所有方程式颜色的宏
问题描述
我正在制作一个包含大量数学方程式的 PowerPoint 演示文稿。我想问一下是否有任何方法可以自动更改这些方程式的颜色。我找到了一个解决方案,但它适用于那里的 Word 文档: https ://www.codeproject.com/Tips/1378034/Macro-to-Change-the-Color-of-all-Equations-in-a-Wo
Sub Change_Equation_Color()
'Macro to Change the Font Color of all Equations in a Word Document
Dim Eq As OMath
For Each Eq In ActiveDocument.OMaths
Eq.Range.Select
Selection.Font.ColorIndex = wdDarkBlue 'Choose Color here, e.g. wdBlack
'Selection.Font.TextColor.RGB = RGB(255, 0, 255) 'To use RGB color, uncomment this line and comment the one above
Next
End Sub
不幸的是,这个宏在 PowerPoint 中不起作用。您能否为此提供任何解决方案?
谢谢!
解决方案
这是 PowerPoint 等价物:
Sub ColorEquation()
Dim oSlide As Slide
Dim oShape As Shape
For Each oSlide In ActivePresentation.Slides
For Each oShape In oSlide.Shapes
If oShape.HasTextFrame Then
If oShape.TextFrame2.HasText Then
If oShape.TextFrame2.TextRange.MathZones.Length > 0 Then
oShape.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(255, 0, 255)
End If
End If
End If
Next oShape
Next oSlide
End Sub
推荐阅读
- python - 如何为 Flask-Admin 视图绑定不同的 Mongoengine 数据库别名?
- javascript - Bootstrap 侧边栏 - 默认折叠?(Metronic HTML 模板)
- typescript - 如何使用 Parcel-bundler 正确转译?
- google-cloud-firestore - Firebase 功能未在创建新文档时触发
- nginx - Nginx 服务器配置:访问没有 php 扩展的分页,并提供专用和单独的 php 文件夹
- spring - 选择查询中的动态变量
- laravel - 资源记录中的 Laravel Nova 指标
- typescript - 我如何访问 Angular 5 中的 SVG 文件
- r - 将应用程序部署到shinyapps.io,该应用程序依赖于本身具有依赖关系的自定义包
- c# - C#:char 数组反转,有 2 种方法,一种具有直接长度的方法。一种有价值的方法。为什么第二种方法不起作用?