PowerPoint VBA单元格着色

时间:2016-07-13 01:21:05

标签: vba macros powerpoint

我希望为PowerPoint编写一个VBA代码,根据代码值改变表格中单元格的颜色。

例如,“ - 2”为红色,“0”为黄色,“+ 1”为绿色。如果不满足这些条件,请不要改变任何颜色。

谢谢!

1 个答案:

答案 0 :(得分:0)

你可以使用这样的东西,而不是你需要的整个代码,但这应该可以帮助你:

With With ActivePresentation.Slides(1).Shapes(3).Table
    If .Cell(y, x).Shape.Fill.BackColor.RGB <> -2 And .Cell(y, x).Shape.Fill.BackColor.RGB <> 0 _
    And .Cell(y, x).Shape.Fill.BackColor.RGB <> 1 Then      'You might have to check an other BackGround property
        .Cell(y, x).Shape.Fill.ForeColor.ObjectThemeColor = 'something
    End If
End With

只需循环遍历所有单元格(将y和x增加到coloumns和行的最大值)