【问题标题】:Modify active table Cell Gradient修改活动表单元格渐变
【发布时间】:2016-12-06 11:17:05
【问题描述】:

我正在尝试调整所选表格中所选单元格的渐变和填充设置。

我已经用 Excel 完成了这项工作。对于 PowerPoint,我管理的最好方法是调整单一填充颜色。我一直在阅读各种网站,但没有任何进展。如何生成下面 Excel 代码中创建的相同效果?

Excel 代码:(工作)

ActiveCell.Select
With Selection.Interior
    .Pattern = xlPatternLinearGradient
    .Gradient.Degree = 90
    .Gradient.ColorStops.Clear
End With
With Selection.Interior.Gradient.ColorStops.Add(0)
    .ThemeColor = xlThemeColorDark1
    .TintAndShade = 0
End With
With Selection.Interior.Gradient.ColorStops.Add(1)
    .Color = 39372
    .TintAndShade = 0
End With

*编辑:有点效果,但对颜色仍然不是 100% 满意。

PowerPoint 代码 (WIP)

Dim oSh As Shape
Dim oTbl As Table
Dim lRow As Long ' your i
Dim lCol As Long ' your j
Set oSh = ActiveWindow.Selection.ShapeRange(1)
Set oTbl = oSh.Table

With oTbl
    For lRow = 1 To .Rows.Count
        For lCol = 1 To .Columns.Count
            If .Cell(lRow, lCol).Selected Then
                With .Cell(lRow, lCol).Shape
                    .Fill.TwoColorGradient msoGradientHorizontal, 1
                    .Fill.ForeColor.RGB = RGB(255, 222, 129)
                    .Fill.BackColor.RGB = RGB(208, 154, 0)
                End With
            End If
        Next
    Next
End With

End Sub

【问题讨论】:

    标签: vba gradient powerpoint


    【解决方案1】:

    我看到你成功了。如果您不喜欢您使用的 RGB 颜色,我会先在 PowerPoint UI 中设计样式,然后对您设计的内容进行编码。要拥有多站(超过 2 个)渐变,您可以像这样添加停靠点:

    Sub TableCellGradient()
      Dim oSh As Shape
      Dim oTbl As Table
      Dim lRow As Long ' your i
      Dim lCol As Long ' your j
      Set oSh = ActiveWindow.Selection.ShapeRange(1)
      Set oTbl = oSh.Table
    
      With oTbl
        For lRow = 1 To .Rows.Count
          For lCol = 1 To .Columns.Count
            If .Cell(lRow, lCol).Selected Then
              With .Cell(lRow, lCol).Shape.Fill
                .TwoColorGradient msoGradientHorizontal, 1
                .ForeColor.RGB = RGB(255, 222, 129)
                .BackColor.RGB = RGB(208, 154, 0)
                .GradientStops.Insert RGB(255, 255, 255), 0.5, 1
              End With
            End If
          Next
        Next
      End With
    End Sub
    

    【讨论】:

    • 太棒了,谢谢,仍然不清楚如何添加额外的站点,这为我清除了。
    • 是的 - 有时您会认为 Office 应用套件是由不同的公司设计的,而在微软的辩护中,它们最初是由不同的公司设计的。
    猜你喜欢
    • 2019-03-26
    • 1970-01-01
    • 2014-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-02
    • 1970-01-01
    • 2017-01-11
    相关资源
    最近更新 更多