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 / Tables / January 2004

Tip: Looking for answers? Try searching our database.

border on last row on multi-page tables

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
synnamone - 20 Jan 2004 22:36 GMT
Does anyone out there know if there's a way to automagically have Word apply a bottom border to the last row on each page of a table that spans multiple pages (Note:  There are no internal horizontal lines in the format we're using)???  Short of going to the the last row on each page and putting it in manually; I can't figure it out.  HELP!!!
Peter Hewett - 22 Jan 2004 04:42 GMT
Hi =?Utf-8?B?c3lubmFtb25l?= (Isn't anonymity a wonderful thing!)

Word can't do what you want automatically. You can't do EXACTLY what you
want at all, as the lines you create are actually table cell borders. So
the bottom of one rows cells are the top of the next - even if the next
rows on the next page. I hope that makes sense if not create a document
with a table that spans two pages and manually format the last row of the
table on the first page and you'll see what I mean.

If this compromise is acceptable, here's some code that may help:

Public Sub TableLines()
   Dim tblTemp As Word.Table
   Dim rowItem As Word.Row
   Dim lngBasePageNo As Long
   Dim lngCurrentPageNo As Long
   Dim lngRowIndex As Long

   ' Do this for ALL tables in the document
   For Each tblTemp In ActiveDocument.Tables

       ' Get the page number of the first row so
       ' that we establish a reference point
       lngBasePageNo = _
         tblTemp.Rows(1).Range.Information(wdActiveEndPageNumber)

       ' Loop through ALL rows in the table
       For lngRowIndex = 1 To tblTemp.Rows.Count

           Set rowItem = tblTemp.Rows(lngRowIndex)

           ' Page number of the current row
           lngCurrentPageNo = _
             rowItem.Range.Information(wdActiveEndPageNumber)

           ' If the page numbers are different we're on a new page, so
           ' that means the previous row must be at the bottom of the
           ' previous page
           If lngBasePageNo <> lngCurrentPageNo Then

               ' Set the previous rows bottom margin to a single line
               SetLine rowItem

               ' Set new base so that we can detect the end of this page
               lngBasePageNo = lngCurrentPageNo
           Else

               ' Always reset the bottom margin to nothing
               ' in case the tables expanded or shrunk
               rowItem.Cells.Borders(wdBorderBottom).LineStyle = _
                      wdLineStyleNone
           End If

           ' Set border for the very last row of the table
           If lngRowIndex = tblTemp.Rows.Count Then SetLine rowItem
       Next
   Next
End Sub

Private Sub SetLine(ByVal rowItem As Word.Row)
   With rowItem.Cells.Borders(wdBorderBottom)
       .LineStyle = wdLineStyleSingle
       .LineWidth = wdLineWidth050pt
       .Color = wdColorAutomatic
   End With
End Sub

Make sure you copy both procedures! For aesthetics sake I've also added a
border at the botttom of the very last row of the table. I've not added a
border at the top of the first table row, because these are often header
rows and consequently are formatted quite differently.

Note: This code reformats ALL tables in your document.

HTH + Cheers - Peter

=?Utf-8?B?c3lubmFtb25l?= <anonymous@discussions.microsoft.com> wrote in
news:0271D824-C8D6-4257-AAC7-0DB4E2873F1E@microsoft.com:

> Does anyone out there know if there's a way to automagically have Word
> apply a bottom border to the last row on each page of a table that spans
> multiple pages (Note:  There are no internal horizontal lines in the
> format we're using)???  Short of going to the the last row on each page
> and putting it in manually; I can't figure it out.  HELP!!!
JGM - 22 Jan 2004 05:09 GMT
Hi synnamone and Peter,

Sorry to butt in... but... this is something I have used many times before.

But I guess I do not understand what synnamone wants, because it seems too
easy to do.

Just in case both of you missed it, at the risk of sounding silly, here it
goes:

Select the whole table;
Call up the Borders & Shading dialog box (Format menu);
Apply only a bottom border to the table (no horizontal or top or left or
right or vertical... I mean it!);
Click OK;
Add rows to your table until it overflows onto second page;
Now you should have a border at the bottom of the last row on the first page
and at the bottom of the table itself on the second page as well.

Isn't that the behaviour you wanted?

Cheers!
--
_______________________________________
Jean-Guy Marcil
jmarcil@sympatico.ca

> Does anyone out there know if there's a way to automagically have Word apply a bottom border to the last row on each page of a table that spans
multiple pages (Note:  There are no internal horizontal lines in the format
we're using)???  Short of going to the the last row on each page and putting
it in manually; I can't figure it out.  HELP!!!
Peter Hewett - 22 Jan 2004 05:46 GMT
Hi JGM

I laughed so hard I nearly fell of my seat (after writing all that code!)
Yeah, your dead right, your suggestion works perfectly!!!!

Thanks - Peter

> Hi synnamone and Peter,
>
[quoted text clipped - 29 lines]
> format we're using)???  Short of going to the the last row on each page
> and putting it in manually; I can't figure it out.  HELP!!!
 
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.