![]() |
|
#2
|
||||
|
||||
|
Forgive my ignorance but ... Is 'Persian' and 'Turkish' being used interchangeably or are they different written languages and both appear in the tables?
You shouldn't iterate through the rows from top to bottom if you are modifying the row count as the loop proceeds. The loop should work from bottom to top. My best guess as to what you are actually requiring is to modify the code this way. If this doesn't work, please post a small sample document that the code is supposed to work on? Code:
Sub fnSplitCellsInNewTableRows()
Dim oTable As Word.Table, iPars As Integer, intRow As Integer
Dim rngParaLast As Range
For Each oTable In ActiveDocument.Tables
If oTable.Columns.Count = 2 And oTable.Uniform Then
For intRow = oTable.Rows.Count To 1 Step -1
With oTable.Rows(intRow)
iPars = .Cells(1).Range.Paragraphs.Count
If iPars = .Cells(2).Range.Paragraphs.Count Then
If iPars > 1 Then
Do While .Cells(1).Range.Paragraphs.Count > 1
.Cells.Split NumRows:=2, NumColumns:=1, MergeBeforeSplit:=False
Set rngParaLast = .Cells(1).Range.Paragraphs.Last.Range
rngParaLast.MoveEnd Unit:=wdCharacter, Count:=-2
oTable.Rows(intRow + 1).Cells(1).Range.FormattedText = rngParaLast.FormattedText
rngParaLast.MoveEnd Unit:=wdCharacter, Count:=1
rngParaLast.MoveStart Unit:=wdCharacter, Count:=-1
rngParaLast.Delete
Set rngParaLast = .Cells(2).Range.Paragraphs.Last.Range
rngParaLast.MoveEnd Unit:=wdCharacter, Count:=-2
oTable.Rows(intRow + 1).Cells(2).Range.FormattedText = rngParaLast.FormattedText
rngParaLast.MoveEnd Unit:=wdCharacter, Count:=1
rngParaLast.MoveStart Unit:=wdCharacter, Count:=-1
rngParaLast.Delete
Loop
End If
Else
.Range.HighlightColorIndex = wdYellow
End If
End With
Next intRow
Else
oTable.Range.HighlightColorIndex = wdBrightGreen 'highlite tables with merged cells or not 2 cols
End If
Next oTable
End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Is there a way to Find multiple text strings in a Word document in a single operation?
|
wrdy | Word | 8 | 04-03-2022 07:22 PM |
| Open Multiple Documents in Single Word 2010 Window? | Clueless in Seattle | Word | 10 | 10-14-2020 08:37 AM |
| Search Multiple Strings and if Present get single word as output | transactions | Excel Programming | 1 | 05-17-2019 11:18 AM |
Merging multiple excel records in to a single word doc?
|
dns_to | Mail Merge | 1 | 10-20-2017 01:22 PM |
Copying Multiple tables from excel into a single word document
|
dineshtgs | Word Tables | 1 | 04-07-2011 01:27 AM |