【问题标题】:VBA-PPT change color of HyperlinksVBA-PPT改变超链接的颜色
【发布时间】:2018-05-14 04:10:05
【问题描述】:

我正在尝试更改 PowerPoint 演示文稿中所有超链接的颜色。

这是我的第一次尝试:

Sub ChangeShapeColor()

Dim oHl As Hyperlinks
Dim oSl As Slide

' Look at each slide in the current presentation:
For Each oSl In ActivePresentation.Slides

    ' Look at each shape on each slide:
    For Each oHl In oSl.Shapes

        ' IF the shape's .Fill.ForeColor.RGB = black color:
        If oHl.Fill.ForeColor.RGB = RGB(0, 0, 0) Then
            ' Change it to corporate yellow:
            oHl.Fill.ForeColor.RGB = RGB(242, 235, 26)
        End If

    Next oHl
Next oSl

End Sub

谢谢你帮助我!

【问题讨论】:

  • 那么,您第一次尝试时发生了什么?
  • 调试器告诉我“填充”参数有问题。
  • 你不应该使用 .Font.Color = RGB(242, 235, 26) 吗?

标签: vba colors hyperlink powerpoint


【解决方案1】:

要调整所有超链接颜色,您可以更改配色方案,特别是方案中的第 11 和第 12 个位置,它们是控制超链接颜色的位置。

以下示例将超链接和后续超链接颜色分别设置为绿色和红色:

Sub SetHyperlinkColors()
    With ActivePresentation.Designs(1).SlideMaster.Theme.ThemeColorScheme
        ' Hyperlink color
        .Colors(11).RGB = RGB(0, 255, 0)
        ' Followed hyperlink color
        .Colors(12).RGB = RGB(255, 0, 0)
    End With
End Sub

这是简化版。它只作用于演示文稿中的第一个设计(即大师)。如果你有多个设计,你会做这样的事情,这也适用于只有一个设计的演示文稿:

Sub SetHyperlinkColors()
    Dim x as Long
    With ActivePresentation
        For x = 1 to .Designs.Count
            With .Designs(x).SlideMaster.Theme.ThemeColorScheme
                ' Hyperlink color
                .Colors(11).RGB = RGB(0, 255, 0)
                ' Followed hyperlink color
                .Colors(12).RGB = RGB(255, 0, 0)   
            End With ' Designs(x)
        Next  ' Design
    End with
End Sub

【讨论】:

    猜你喜欢
    • 2015-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-01
    • 2021-01-17
    • 1970-01-01
    • 2021-05-14
    相关资源
    最近更新 更多