Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

Macro to Add Borders to Tables

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mmikedm1000 - 28 Nov 2005 23:32 GMT
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,
Signature

Michael

Jay Freedman - 29 Nov 2005 03:10 GMT
>Hi,
>
[quoted text clipped - 3 lines]
>
>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        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
mmikedm1000 - 29 Nov 2005 21:05 GMT
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
Signature

Michael

> >Hi,
> >
[quoted text clipped - 35 lines]
> Email cannot be acknowledged; please post all follow-ups to the
> newsgroup so all may benefit.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.