Looping through a table to merge blank cells
Hello. I'm used to using VB for Excel but this is something that has to be done in Word and I'm not quite sure how to approach it.
I've got some documents with tables. For each row, I'd like to check IF the third cell (Column 3) is blank, and if so then MERGE with the cell above it. I want this to contine for all rows in the table. So far I get error messages of "Object does not support this function" or something.
Here's my code so far:
Code:
Sub mergeCells()
Dim myTable As Table
Set myTable = ActiveDocument.Tables(1)
Dim myRange As Range
Dim oCell As Word.Cell
Dim oRow As Word.Row
LR = myTable.Rows.Count
For i = 1 To LR
If myTable.Cell(i, 3).Range.Text = Chr(13) & Chr(7) Then
topcell = myTable.Cell((i - 1), 3)
Set myRange = ActiveDocument.Range(topcell _
.Range, myTable.Cell(i, 3).Range)
myRange.Cells.Merge
End If
Next i
thanks for any help in advance.