Prevent split cells from being split between pages

I am trying to write a program to create a Microsoft Word document from an Oracle table.

There are tables in the document with a left column that represents the field name of a group, and the next column has some fields associated with that group. I don't want groups to be paginated. My code for this doesn't work, groups are still split between pages.

Does anyone know how to do this?

'output table data - data gets loaded into the display table starting at row 3
'(row 1 and 2 are the headers)
For row = 3 To maxrows + 2
    Dim dataRow = dsHDTabCols.Tables(0).Rows(row - 3)  'dataset has rows to output
    If dataRow("KEEP_WITH_NEXT_FLAG") & "" = "K" Then
        oTable.Cell(row, 1).Range.ParagraphFormat.KeepWithNext = True 
    End If
    If dataRow("GROUP_NAME") & "" = "@ditto@" Then 
        VerticalMergeWithPriorRow(oTable, row, 1) 
    Else 
        oTable.Cell(row, 1).Range.Text = dataRow("GROUP_NAME") & "" 
    End If
    oTable.Cell(row, 2).Range.Text = dataRow("COLUMN_NAME") & "" 

      

Note that I am vertically merging cells, so I am limited to using links table.cell

.

Table.rows (nnn) `throws an exception.

The data processed by the above code starts with a data line with the keep_with_next_flag parameter set to "K", so the code sets the cell paragraph format to keepwithnext = true.

The next line of data in the group will have the group name = "@ditto @" and keep_with_next_flag will have "K". As above, the code sets the cell's paragraph format with keepwithnext = true. Since it is the same, the code will execute the VerticalMergeWithPriorRow function, which simply concatenates the current cell with the cell in the same column but in the previous row.

+3


source to share





All Articles