Hi Everyone,
I have a .txt file that has been exported from Business Objects. I am formatting the file as a word document and then converting the text to a table. The resulting table can be in excess of 2000 rows. Each range of data within the table is separated by a blank row. I want to split the table into multiple tables at the blank row separating the data range.
I have tried the following code snippet, but the loop ceases at the first split (because the table is now two tables and not one table).
Can anyone tell me how to continue with the loop until all blank rows have been found leaving me with a separate table for each data range.
I know this may be a slow process due to the way that tables work in Word. Is there a way to do this in Excel, but reference the Excel document from within Word? I will need to find text in each data range, hence the need for separate tables.
Dim eRow as Row
Dim newTable as Table
Dim targetDoc as Document
For Each eRow In newTable.Rows
i = targetDoc.Tables.Count
Set newTable = targetDoc.Tables(i)
eRow.Select
If eRow.Cells(3).Range.Text = Chr(13) & Chr(7) Then
Selection.SplitTable
Selection.MoveDown wdLine, 1, wdMove
eRow.Select
End If
Next
Next
I have a .txt file that has been exported from Business Objects. I am formatting the file as a word document and then converting the text to a table. The resulting table can be in excess of 2000 rows. Each range of data within the table is separated by a blank row. I want to split the table into multiple tables at the blank row separating the data range.
I have tried the following code snippet, but the loop ceases at the first split (because the table is now two tables and not one table).
Can anyone tell me how to continue with the loop until all blank rows have been found leaving me with a separate table for each data range.
I know this may be a slow process due to the way that tables work in Word. Is there a way to do this in Excel, but reference the Excel document from within Word? I will need to find text in each data range, hence the need for separate tables.
Dim eRow as Row
Dim newTable as Table
Dim targetDoc as Document
For Each eRow In newTable.Rows
i = targetDoc.Tables.Count
Set newTable = targetDoc.Tables(i)
eRow.Select
If eRow.Cells(3).Range.Text = Chr(13) & Chr(7) Then
Selection.SplitTable
Selection.MoveDown wdLine, 1, wdMove
eRow.Select
End If
Next
Next