View Single Post
 
Old 10-27-2020, 01:32 AM
bpike bpike is offline Windows 10 Office 2019
Novice
 
Join Date: Oct 2020
Posts: 8
bpike is on a distinguished road
Default Splitting Tables containing Merged Cells

Hi all,

I'm hoping someone can help me with splitting tables that contain merged cells?

My macro works fine in a regular table, however, if there are any merged cells present I receive a Run-time error '-2147024808 (80070057)': Object has been deleted.

My code is as follows:

Code:
Sub SplitTable()

Dim oTbl As Word.Table, oRow As Row, oCell As Cell


For Each oTbl In ThisDocument.Tables
      
    n = 1
        Do While n > 0
        For Each oCell In oTbl.Range.Cells
        If oCell.Range = "Tree Number" & Chr(13) & Chr(7) Then n = oCell.RowIndex
        Next
        If n = 1 Then Exit Do
        oTbl.Split (n)
        n = 1
     
        Loop

Next oTbl

End Sub


Any workaround will be much appreciated.

Last edited by macropod; 10-27-2020 at 02:34 AM. Reason: Added code tags
Reply With Quote