Macro to Add Borders to Tables

M

mmikedm1000

Hi,

I have tables in word documents that need to have borders around them. I am
trying to write a macro that will find the tables and add a border all around
and in the tables. Any help would be appriciated.

Thanks,
 
J

Jay Freedman

Hi,

I have tables in word documents that need to have borders around them. I am
trying to write a macro that will find the tables and add a border all around
and in the tables. Any help would be appriciated.

Thanks,

You could do something like this:

Sub TableBorders()
Dim oTbl As Table
For Each oTbl In ActiveDocument.Tables
With oTbl.Borders
.OutsideLineStyle = wdLineStyleSingle
.OutsideLineWidth = wdLineWidth225pt
.OutsideColorIndex = wdAuto
.InsideLineStyle = wdLineStyleSingle
.InsideLineWidth = wdLineWidth050pt
.InsideColorIndex = wdGray50
End With

With oTbl.Rows(1).Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
.ColorIndex = wdGray50
End With
Next oTbl
End Sub

Many more options are available -- put the cursor on the word Borders
in the code and press F1 to see the topic.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
M

mmikedm1000

Thanks,

That worked great. I had tried defining a new talbe style with borders and
than having the macro change the style of talbes to a the new style, but that
created some strange tables.

Again,
Thanks for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top