• Status: Solved
  • Priority: High
  • Security: Public
  • Views: 77
  • Last Modified:

problem with last line of a table in Microsoft Word

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
0
thenelson
Asked:
thenelson
  • 5
  • 2
1 Solution
 
ITSysTechSenior Systems AdministratorCommented:
If you click on an effected cell what does "Text Direction" show?

1.JPG
0
 
ITSysTechSenior Systems AdministratorCommented:
Also, try changing the alignment to "Top".

1.JPG
0
 
thenelsonAuthor Commented:
Text direction is normal:text direction
Alignment is already set to top:
alignment.png
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
ITSysTechSenior Systems AdministratorCommented:
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?
0
 
thenelsonAuthor Commented:
There are no images.  This problem usually (but not always) occurs when I copy and paste the table from another Word document.
0
 
ITSysTechSenior Systems AdministratorCommented:
Could you go to file>options>advanced and post what you have?

1.JPG
0
 
ITSysTechSenior Systems AdministratorCommented:
Inactive for 14 days
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now