如何解决在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,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,255)
End If
End If
End If
Next oShape
Next oSlide
End Sub
,
在第 8 行使用 Count 而不是 Length。
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.Count > 0 Then
oShape.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(255,255)
End If
End If
End If
Next oShape
Next oSlide
End Sub
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。