none
VBA Excel to PowerPoint - Color entire row RRS feed

  • Question

  • Hi all,

    I have a program in Excel that builds a table in PowerPoint and fills this with Excel data.

    The code:

    Set Data = newPowerPoint.ActivePresentation.Slides(2).Shapes.AddTable(12, 17)
            With Data
    
    ColoredColumns = RGB(243, 200, 167)
    
    .Table.cell(1, 2).Shape.Fill.ForeColor.RGB = ColoredColumns
    
    End With

    As you can see, I'm able to color the cell the way I want to. Problem is, I need to color 92 cells with the same color and that is taking to much space if I do this cell by cell.

    Is it possible to color an entire column? If yes, how?

    Thanks!

    Ganesh

    Friday, January 20, 2017 10:38 PM

Answers

  • Hi,

    PowerPoint does not provide any properties to color entire row/column.

    To fill rows or columns, we need to loop each cell.

    E.g.

     For Row = 1 To Data.Table.Rows.Count
            For col = 1 To Data.Table.Columns.Count
                Set shp = Data.Table.Cell(Row, col).Shape
                shp.Fill.ForeColor.RGB = ColoredColumns
            Next col
        Next Row

    Besides, you could see the demo: PowerPoint 2010: Set Background Fill in Tables Using PPT.TableBackground

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by ganeshgebhard Monday, January 23, 2017 9:07 AM
    Monday, January 23, 2017 4:35 AM
    Moderator

All replies

  • Hi,

    PowerPoint does not provide any properties to color entire row/column.

    To fill rows or columns, we need to loop each cell.

    E.g.

     For Row = 1 To Data.Table.Rows.Count
            For col = 1 To Data.Table.Columns.Count
                Set shp = Data.Table.Cell(Row, col).Shape
                shp.Fill.ForeColor.RGB = ColoredColumns
            Next col
        Next Row

    Besides, you could see the demo: PowerPoint 2010: Set Background Fill in Tables Using PPT.TableBackground

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by ganeshgebhard Monday, January 23, 2017 9:07 AM
    Monday, January 23, 2017 4:35 AM
    Moderator
  • Hi Celeste,

    Thanks for the reply.

    I managed to do it the following way:

    For i = 1 To 12
                    .Table.cell(i, 16).Shape.Fill.ForeColor.RGB = RGBCode
                Next

    Monday, January 23, 2017 9:07 AM