Home | VBA Section | General Section | Downloads | Licensing | Privacy Policy

Set table border colour

 

No direct methods are available to set the table border property for native PowerPoint tables. However since the PowerPoint table just special collection of shapes, you can create a simple wrapper to achieve it. This can be extended to apply various border styles.

 
' ---------------------------------------------------------------------
' Copyright ©1999-2007 Shyam Pillai. All Rights Reserved.
' ---------------------------------------------------------------------
' You are free to use this code within your own applications, add-ins,
' documents etc but you are expressly forbidden from selling or
' otherwise distributing this source code without prior consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
' ---------------------------------------------------------------------
Option Explicit
Sub HowToUseIt()
Call SetTableBorder(ActivePresentation.Slides(1).Shapes(1).Table)
End Sub
Sub SetTableBorder(oTable As Table)
Dim I As Integer
With oTable
    For I = 1 To .Rows.Count
        With .Rows(I).Cells(1).Borders(ppBorderLeft)
            .ForeColor.RGB = RGB(255, 0, 0)
            .Weight = 5
        End With
        With .Rows(I).Cells(.Rows(I).Cells.Count).Borders(ppBorderRight)
            .ForeColor.RGB = RGB(255, 0, 0)
            .Weight = 5
        End With
    Next I
    For I = 1 To .Columns.Count
        With .Columns(I).Cells(1).Borders(ppBorderTop)
            .ForeColor.RGB = RGB(255, 0, 0)
            .Weight = 5
        End With
        With
.Columns(I).Cells(.Columns(I).Cells.Count).Borders(ppBorderBottom)
            .ForeColor.RGB = RGB(255, 0, 0)
            .Weight = 5
        End With
    Next I
End With
End Sub
 
 
 

Copyright © 1999-2008 Shyam Pillai. All rights reserved.