problem with last line of a table  in Microsoft Word

thenelson
thenelson used Ask the Experts™
on
Occasionally, the bottom gridline of a table in Microsoft Word disappears (see image below). bottom gridline missingI have tried many ways to correct this: reformat the table, add a line, etc but nothing works to get the gridline back.

When I use the following code:
Sub GetAvg()
Dim cellLoop As Cell, CellContents, datePreviousVisit, intColumnIndex As Integer

intColumnIndex = Selection.Cells(1).ColumnIndex
Selection.GoTo wdGoToBookmark, , , "VitalSigns"
Selection.MoveDown wdLine, 1
Selection.HomeKey wdLine
Selection.MoveRight wdWord, 5, wdExtend
If IsDate(Selection.Range.Text) Then
    datePreviousVisit = InputBox("Enter Fill date:", , CDate(Selection.Range.Text))
Else
    datePreviousVisit = InputBox("Enter Fill date:")
End If
If Len(datePreviousVisit & "") = 0 Then Exit Sub Else datePreviousVisit = CDate(datePreviousVisit)
'Debug.Print Format(datePreviousVisit, "mmm dd, yyyy")
For Each cellLoop In ActiveDocument.Tables(3).Columns(intColumnIndex).Cells
        CellContents = Split(Left(cellLoop.Range.Text, Len(cellLoop.Range.Text) - 2), ",")
        If UBound(CellContents) = 1 Then
            cellLoop.Range.Text = Trim(CellContents(0))
            If CellContents(1) = "" Then CellContents(1) = 0
            cellLoop.Range.Text = Trim(CellContents(0)) & ", " & Trim(CellContents(1)) & ", " & Trim(Round((cellLoop.Range.Calculate - CellContents(1)) / DateDiff("d", datePreviousVisit, ActiveDocument.Bookmarks("DOS").Range.Text), 1))
        End If
Next cellLoop
ActiveDocument.Tables(3).Cell(1, intColumnIndex).Select
End Sub

Open in new window

with the missing gridline, I get this error message: "run time error 5992; Cannot access individual columns  in this collection because the table has mixed cell widths."

Is there a way to get the gridline back or a way to change the code so it runs with the missing gridline?

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
ITSysTechSenior Systems Administrator

Commented:
If you click on an effected cell what does "Text Direction" show?

1.JPG
ITSysTechSenior Systems Administrator

Commented:
Also, try changing the alignment to "Top".

1.JPG
Text direction is normal:text direction
Alignment is already set to top:
alignment.png
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

ITSysTechSenior Systems Administrator

Commented:
There must be something causing this like a photo or your header. Have you tried to rearrange images on your document if you have any?
There are no images.  This problem usually (but not always) occurs when I copy and paste the table from another Word document.
Senior Systems Administrator
Commented:
Could you go to file>options>advanced and post what you have?

1.JPG
ITSysTechSenior Systems Administrator

Commented:
Inactive for 14 days

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial