Log in

View Full Version : [SOLVED:] Remove only outside table borders - updating code



StarPig
02-17-2023, 05:16 AM
Hi Andy / John

I've been trying to write code to remove only the 4 outside borders of any table that's selected. I found this closest code by Andy (after hours of googling and editing codes I've found online), but it's from 2006 and no longer works:
http://www.vbaexpress.com/forum/showthread.php?8751-Solved-Removing-a-table-s-Outline-border

Any help would be much appreciated, as always, thank you.



Dim tblTemp As Table

Set tblTemp = ActivePresentation.Slides(1).Shapes(3).Table
With tblTemp
.Rows(1).Cells.Borders.Item(ppBorderTop).Visible = msoFalse
.Rows(.Rows.Count).Cells.Borders.Item(ppBorderBottom).Visible = msoFalse
.Columns(1).Cells.Borders.Item(ppBorderLeft).Visible = msoFalse
.Columns(.Columns.Count).Cells.Borders.Item(ppBorderRight).Visible = msoFalse
End With


It's just to remove (or make white to hide) the outside borders of any table, no matter how many rows or columns it has, no existing inside borders are changed.

Thank you

Aussiebear
02-17-2023, 12:22 PM
Does this work for you


Sub ClearBorders()
Dim b as Variant
For each in Array(xlEdgeTop, xlEdgeBottom, xlEdgeleft, XlEdgeRight)
Selection.Borders(b).Linestyle = xlNone
Next
End Sub

John Wilson
02-18-2023, 02:17 AM
There's a long standing bug in the Object Model. I have reported it several times!

Possible workarounds

1. Select the cell (with code) and run

CommandBars.ExecuteMso("BordersNone")
You will get an error if the cell is not selected.

2 Set the Border to .Transparency=1

Aussiebear
02-18-2023, 03:52 AM
Thank you John