• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1376
  • Last Modified:

Shading rows in a PPT table using VBA

I am trying to find the syntax to shade certain rows in powerpoint table

There are currently multiple tables in a template that are automatically updated using vba, and sometimes the lists have different number of rows. the code that i use to currently populate the tables is below.

Case 1 - The cell that was just populated needs to have the background color changed to grey.

Any suggestions or ideas on how to do it are greatly appreciated...
Private Sub TableUpdate(strShapeName As String, iRowCount As Integer, iColCount As Integer, iColCopy As Integer, iRowCopy As Integer, bFormat As Boolean)
Dim rngFormat As Range
rngFormat = False

If bFormat = True Then
rngFormat = Range("nrTableFormattingStart")

i = 1   'Row Counter for Paste Section
j = 1   'column Counter for Paste Section
k = iRowCopy
l = iColCopy

    'Set oPPTShape = strShapeName
    Do Until i > iRowCount
        Do Until j > iColCount
                oPPTShape.Table.cell(i, j).Shape.TextFrame.TextRange.Text = Cells(k, l).Text
            Select Case rngFormat
            Case 0
            Case 1
                'shade the background of the cell grey
            Case 2
                'Merge the first 4 cells of the table
            Case Else
            End Select
            j = j + 1
            l = l + 1
            Set rngFormat = rngFormat.Offset(1, 0)
        i = i + 1
        k = k + 1
        j = 1
        l = iColCopy
End Sub

Open in new window

1 Solution

opptshape.Table.Cell(i, j).Shape.Fill.ForeColor.RGB = RGB(175, 175, 175)

Open in new window

DekkaGAuthor Commented:
You are two for two. This also worked just right.


Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now