Pandi Muthu
Pandi Muthu

Reputation: 29

Remove table border in powerpoint

The code is successfully removing table borders and is fine on screen.

While printing or print previewing, its showing some table border. How to fix it?

 Sub Tableformatting ()
    Dim r As Long, c As Long
    Dim t As Table
      Set t = ActiveWindow.Selection.ShapeRange.Table
            For r = 1 To t.Rows.Count
            For c = 1 To t.Columns.Count
                With t.Cell(r, c)

                    .Borders(ppBorderTop).Transparency = 0
                    .Borders(ppBorderTop).Weight = 0
                    .Borders(ppBorderBottom).Transparency = 0
                    .Borders(ppBorderBottom).Weight = 0
                    .Borders(ppBorderLeft).Transparency = 0
                    .Borders(ppBorderLeft).Weight = 0

                    .Borders(ppBorderRight).Transparency = 0
                    .Borders(ppBorderRight).Weight = 0

                End With
            Next c
        Next r
    End Sub

Upvotes: 2

Views: 3319

Answers (1)

Z Engstrom
Z Engstrom

Reputation: 86

Try using

Sub Tableformatting()
Dim r As Long, c As Long
Dim t As Table

Set t = ActiveWindow.Selection.ShapeRange.Table

For r = 1 To t.Rows.Count
    For c = 1 To t.Columns.Count
        With t.Cell(r, c)
            .Borders(ppBorderTop).Transparency = 1
            .Borders(ppBorderBottom).Transparency = 1
            .Borders(ppBorderLeft).Transparency = 1
            .Borders(ppBorderRight).Transparency = 1
        End With
    Next c
Next r
End Sub

For some reason .Transparency = 0 only works for what is actively seen, but .Transparency = 1 works for everything you asked for. It might be a bug on Microsoft's end because I don't see why this method or .Borders.Visible = msoFalse wouldn't work just for print/print preview.

Either way I hope this helped!

Upvotes: 3

Related Questions