Add a bottom border to last row in a table where the insertion point currently is

A

andreas

Hello,
I just want to add a bottom border to the last row in a table where
the insertion point is currently blinking. How can I achieve this
using VBA.
Help is appreciated. Thank you very much in advance.

Regards,

Andreas
 
H

Helmut Weber

Hi Andreas,

what is a bottom border?
Ende-Abstand?

Maybe like this,
though I don't understand what it is good for,
and I think, the same effect could be achieved
by an additional linebreak or simply a paragraph.

Sub Test600()
With Selection.Tables(1).Range.Characters.Last.Next.ParagraphFormat
.LineSpacingRule = wdLineSpaceExactly
.LineSpacing = 36
End With
End Sub

HTH
 
A

andreas

Hello,
I just want to add a bottom border to the last row in a table where
the insertion point is currently blinking. How can I achieve this
using VBA.
Help is appreciated. Thank you very much in advance.

Regards,

Andreas


Hello,

found out myself. Or is there a BETTER WAY than the one below?

Sub ApplyBottomBorderLastRow()
Selection.Tables(1).Select
Selection.Rows(Selection.Information(wdMaximumNumberOfRows)).Borders(wdBorderBottom).LineStyle
= wdLineStyleSingle
Selection.Rows(Selection.Information(wdMaximumNumberOfRows)).Borders(wdBorderBottom).LineWidth
= wdLineWidth050pt


End Sub
 
G

Greg Maxey

Well if your ways works I suppose it is good enough. As a personal
preference I avoid working with the Selection so I would do it like
this:

Sub ApplyBottomBorderLastRow()
Dim myTable As Word.Table
Set myTable = Selection.Tables(1)
With myTable.Rows.Last.Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
End With
End Sub
 
A

andreas

Well if your ways works I suppose it is good enough. As a personal
preference I avoid working with the Selection so I would do it like
this:

Sub ApplyBottomBorderLastRow()
Dim myTable As Word.Table
Set myTable = Selection.Tables(1)
With myTable.Rows.Last.Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
End With
End Sub





- Zitierten Text anzeigen -

Greg,

as always. Thank you very much for your valuable help.
Regards, Andreas
 

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