I have a macro that adds a few cells to the end of a table. I need the bottom border of the added bottom row to extend to the end of the page with one line of text below it. Just below the table is a line of text that contains the string "DCR-0055". The code below accomplishes what I want to do but I think it is sloppy. It changes the cell row height rule to exact, and then in a while loop it adds .25 inches to the row height until the "DCR-0055" string is no longer on the page and then subtracts back enough space to put the line back on the same page.
Is there a better way to do this?
Code:
Set currentPage = ActiveDocument.Bookmarks("\Page").Range
Dim heightValue As Single
heightValue = 0.15
Application.ScreenUpdating = False
With ActiveDocument.Tables(tableNum).Cell(startX + 3, 1)
.HeightRule = wdRowHeightExactly
Do While InStr(currentPage, "DCR-0055") > 0
.SetHeight RowHeight:=InchesToPoints(heightValue), HeightRule:=wdRowHeightExactly
heightValue = heightValue + 0.25
Set currentPage = ActiveDocument.Bookmarks("\Page").Range
Loop
.SetHeight RowHeight:=InchesToPoints(heightValue - 0.45), _
HeightRule:=wdRowHeightExactly
End With
Application.ScreenUpdating = True