'Add Border Color to all tables Powerpoint VBA
Trying to add a border color to all tables in Powerpoint and failing. I'm not very good at this.
Sub SetTableBorder()
Dim oShp As Shape
Dim oTbl As Table
Dim oSld As Slide
For Each oSld In ActivePresentation.Slides
For Each oShp In oSl.Shapes
If oShp.HasTable Then
With oShp.Table
.Borders(ppBorderTop).ForeColor.RGB = RGB(235,186,182)
.Borders(ppBorderBottom).ForeColor.RGB = RGB(235,186,182)
.Borders(ppBorderLeft).ForeColor.RGB = RGB(235,186,182)
.Borders(ppBorderRight).ForeColor.RGB = RGB(235,186,182)
End With
End If
Next oShp
Next oSld
End Sub
Solution 1:[1]
First, correct the typo: oSl.Shapes --> oSld.Shapes Next, add Option Explicit above all the subs/functions in this (and ideally all other) module. That'll prevent this kind of thing from biting you.
Next, you want to work with the table's .Rows(1).Cells.Borders(ppBorderTop) and its various properties to set the top border,
Something like .Rows(.Rows.Count).Cells ... etc to set the bottom border for the table.
Then similarly, .Columns(1).Cells ... properties ... to set the left border.
And so on.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Steve Rindsberg |