A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Double Vertical Borders in Tables



 
 
Thread Tools Display Modes
  #1  
Old September 1st, 2004, 01:35 PM
Rashid Khan
external usenet poster
 
Posts: n/a
Default 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  
Old September 1st, 2004, 03:06 PM
Jay Freedman
external usenet poster
 
Posts: n/a
Default

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  
Old September 1st, 2004, 07:12 PM
Rashid Khan
external usenet poster
 
Posts: n/a
Default

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 10:13 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.