Double Vertical Borders in Tables

R

Rashid Khan

Hello All,
I am using Office XP. I have a document with many tables of various
columns... i.e. 2 cols, 3 cols, 4 cols, 5 cols......All tables have an
outside single borders and vertical single borders.
I need to have a macro which would draw a double vertical borders between
2nd and 3rd columns on all the tables that are 4 Cols. Other tables should
be left intact.

Can this be achieved through VBA?

Any help would be suggested. At present I do it manually.
TIA
Rashid
 
J

Jay Freedman

Rashid said:
Hello All,
I am using Office XP. I have a document with many tables of various
columns... i.e. 2 cols, 3 cols, 4 cols, 5 cols......All tables have an
outside single borders and vertical single borders.
I need to have a macro which would draw a double vertical borders
between 2nd and 3rd columns on all the tables that are 4 Cols. Other
tables should be left intact.

Can this be achieved through VBA?

Any help would be suggested. At present I do it manually.
TIA
Rashid

Hi Rashid,

This should do:

Sub DoubleBorder()
Dim oTbl As Table

On Error Resume Next

For Each oTbl In ActiveDocument.Tables
If oTbl.Columns.Count = 4 Then
oTbl.Columns(2).Borders(wdBorderRight) _
.LineStyle = wdLineStyleDouble
End If
Next oTbl
End Sub

It has one limitation: if a 4-column table contains any horizontally merged
cells, the border in that table will not be changed. That's because trying
to do anything with the Columns collection in such a table causes an error
(hence the On Error statement, which causes the macro to ignore the table).
If this is a problem for you, please reply in the newsgroup.
 
R

Rashid Khan

Hi Jay,
Thanks for your quick response.
It works like a charm. You r a genious.

Rashid
 
Top