vba - PPT VBA:将形状的强调色从一种主题颜色更改为另一种
问题描述
在 PPT VBA 中,我试图将文件中具有一种强调色的所有形状更改为另一种。我将此表单中的值提供给我的函数,但它不接受 OldColor 和 NewColor (themecolors) 作为 msoThemeColorAccent1,而是只接受 15。但是当我为 Fill.ForeColor.ObjectThemeColor 提供 msoThemeColorAccent1 时,它是可以接受的;从函数参数提供时不接受。有人可以提出解决方案吗?
这些是我的代码块:
Private Sub cmdApply_Click()
ReplaceColors cboOldColor.Value, cboNewColor.Value, cboOldTint.Text, cboNewTint.Text
End Sub
Sub ReplaceColors(OldColor As Variant, NewColor As Variant, OldTint As String, NewTint As String)
Dim i As Integer
Dim t As Integer
Dim oSld As Slide
Dim oShp As Shape
Dim x, y As Integer
Dim sBrightness
Dim oColor, nColor As ThemeColor
Dim oPP As Placeholders
For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
'groups
If oShp.Type = msoGroup Then
'not groups
Else
With oShp 'other shapes
' Fill
If .Fill.ForeColor.ObjectThemeColor = OldColor And .Fill.ForeColor.Brightness = OldTint Then
.Fill.ForeColor.ObjectThemeColor = NewColor
.Fill.BackColor.Brightness = NewTint
End If
' Line
If Not .Type = msoTable Then
If .Line.Visible = msoTrue Then
If .Line.ForeColor.ObjectThemeColor = OldColor And .Line.ForeColor.Brightness = OldTint Then
.Line.ForeColor.ObjectThemeColor = NewColor
.Line.ForeColor.Brightness = NewTint
End If
End If
End If
' Text
If .HasTextFrame Then
If .TextFrame.HasText Then
For y = 1 To .TextFrame.TextRange.Runs.count
If .TextFrame.TextRange.Runs(y).Font.Color.ObjectThemeColor = OldColor And .TextFrame.TextRange.Runs(y).Font.Color.Brightness = OldTint Then
.TextFrame.TextRange.Runs(y).Font.Color.ObjectThemeColor = NewColor
.TextFrame.TextRange.Runs(y).Font.Color.Brightness = NewTint
End If
Next
End If
End If
End With
End If
'oShp = Nothing
Next oShp
Next oSld
End Sub
解决方案
推荐阅读
- sql - 如何在postgres中获取每个日期的数据计数
- android - Kotlin 协程 UI 未冻结
- python - TidBit 电脑商店的信用计划
- python-3.x - 为什么这个特定的 if 条件永远不会执行?[如果中间 < k <= 正确:]
- java - oracle.net.ns.NetException :ORA-12505, TNS:listener 目前不知道 Oracle18c ExpressEdition 中连接描述符中给出的 SID
- javascript - setTransform 和 Scale 以适合给定图像的 Canvas
- javascript - 如何进行带有错误响应的 JSON api 调用?
- swift - 如何在 SwiftUI 视图上禁用用户交互?
- ruby - 如何根据 ruby 中的日期范围在 mongo 集合中查找文档
- excel - 如何在excel中将具有相同ID的多列相乘