If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Double Vertical Borders in Tables
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 |
#2
|
|||
|
|||
Rashid Khan wrote:
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. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org |
#3
|
|||
|
|||
Hi Jay,
Thanks for your quick response. It works like a charm. You r a genious. Rashid "Jay Freedman" wrote in message ... Rashid Khan wrote: 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. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro to Draw Borders on All Tables | Rashid Khan | Tables | 5 | August 24th, 2004 06:29 PM |
Mutliple Tables lookup? | Westley | Database Design | 4 | June 15th, 2004 01:07 AM |
Excel Chart Vertical Lines Corrupting? | Ken Black | Charts and Charting | 4 | June 4th, 2004 09:16 PM |
Bug in Word - Formatting Tables with double grids | DB | Tables | 0 | May 11th, 2004 06:35 PM |
Adding vertical data tables | tommy calahan | Charts and Charting | 2 | January 15th, 2004 02:55 PM |