Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 09-14-2022, 02:46 AM
a-friend a-friend is offline How to convert a single row into multiple in MS Word? Windows 10 How to convert a single row into multiple in MS Word? Office 2016
Novice
How to convert a single row into multiple in MS Word?
 
Join Date: Sep 2022
Posts: 3
a-friend is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
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
The intention is that any time the inputs don't match, the table or rows will be highlighted.
Hello
You are more than welcome. Thank you very much for the reply. I edited the thread. I have another Turkish file which has the identical data and I have no idea why they got merged in my mind. So I am sorry for making you confused and thank you for letting me know about it.
As for the code you offered, it just changes the contents' predefined white color into yellow and stops working.

The problem is that if it works, the code should include an exception too. (I guess I can bring it up here now.)

Some sentences either in English and in Persian have some 'notes' under them which should be attached to them. Probably, the code does not consider it and will put the say English note into a separate row and whereas there is no corresponding note for that in the right cell (including the Persian equivalent,) the right cell would be left empty and the code will keep going ahead doing its task. The problem is that when the whole work is done, there would be an extra work on these notes.

That said, in a single row, say the right cell might include 10 sentences, but the left cell can have less or more sentence in which the extra sentences are definitely the 'notes' which are preceded by their respective sentence.

The same goes with the Persian cells.

I was wondering how we can include this exception in the code?
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert a single row into multiple in MS Word? 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
How to convert a single row into multiple in MS Word? Merging multiple excel records in to a single word doc? dns_to Mail Merge 1 10-20-2017 01:22 PM
How to convert a single row into multiple in MS Word? Copying Multiple tables from excel into a single word document dineshtgs Word Tables 1 04-07-2011 01:27 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:43 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft