Nathan Franklin was telling us:
Nathan Franklin nous racontait que :
> Hey Jean,
>
> WordRow is set like this
>
> WordRow = Doc.Tables.Item(1).Rows.Add
OK. When you add a row, word formats the new last row like what used to be
the last row.
In this case, if Cells(1) of the last row has a bottom border, when Word
adds a row, the new Cells(1) also has a bottom border. But, what used to be
Cells(1) of the last row (now the one before last) does not have a bottom
border anymore because wdBorderBottom applies only to the last row of the
selection
For example, if you select 3 rows and use wdBorderBottom, only the third row
will have a "bottom" border. Whereas if you had used wdBorderHorizontal,
then row 1 and 2 would have had a "bottom" border. To get all three rows
with a "bottom border", you have to use both wdBorderHorizontal and
wdBorderBottom.
To see what I mean, add a table to a page, apply a bottom border to the last
row, place the cursor in the last cell of this last row and hit TAB to add a
row manually, see the new last row has a bottom border, but the row before
last that used to have a border does not have on anymore?
Delete the table, insert a new one, now add a bottom border to the last two
rows of the table. Add a row with TAB and see the diffrence.
So, if you add a row, and you want what used to be the last cell of the row
to keep its bottom border, if it had one, try this:
'_______________________________________
Dim Doc As Document
Dim WordRow As Row
Dim LastRow As Row
Dim CellBorder As Long
Set Doc = ActiveDocument
With Doc.Tables(1)
Set WordRow = .Rows(.Rows.Count)
CellBorder = WordRow.Cells(1).Borders(wdBorderBottom).LineStyle
Set LastRow = .Rows.Add
LastRow.Cells(1).Borders(wdBorderBottom) _
.LineStyle = wdLineStyleSingle
WordRow.Cells(1).Borders(wdBorderBottom) _
.LineStyle = CellBorder
End With
'_______________________________________
To use wdBorderHorizontal, your selection must have at least two cells in
two consecutive rows. If you have only one cell, nothing will happen as
there isn't an horizontal border separating two cells, and if you try it
with only one cell in the last row, you get an error because there cannot be
an horizontal border between two cells when the first cell in the selection
is in the last row.
I do not know if what I wrote makes any sense, if does not, try stepping
through the code a few times, then try again but comment out
WordRow.Cells(1).Borders(wdBorderBottom) _
.LineStyle = CellBorder
to see the difference.
Also, try this code with different types of cell selection to see how it
works:
Selection.Cells.Borders(wdBorderHorizontal).LineStyle = wdLineStyleSingle
Finally, the same applies to Top, Left, Right (These last two are related to
wdBorderVertical)

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org