Split a cell in a Word table based on text
SebCH81 -
Hello,
I have a rather long text (a little over 35 pages) that I would like to turn into a table.
The text is structured as follows:
"Title 1
Subtitle 1
Text
Subtitle 2
Text
Subtitle 3
Text
Title 2
Subtitle 1
Text
Subtitle 2
Text
Title 3
..."
I would like to format it into a table where each cell contains a Title: cell 1 = Title 1 and its content; cell 2 = Title 2 and its content; cell 3 = Title 3 and its content, etc.
Since there are almost a hundred title elements, I thought this would take quite a bit of time to do manually. Therefore, I thought a VBA Macro could help me, but I am a complete novice in VBA and don't know if this is possible or how to do it.
The titles always start with the same text. So, I imagined putting everything in one cell and creating a macro to split the cell when reaching a title, but I am struggling to see how to accomplish this.
If someone could guide me in the right direction, that would be really nice.
Thank you and have a great day!
2 answers
-
Hello
Actually, if I understood correctly, you want to create a single-column table, with as many cells as there are titles, subtitles, and text.
When you say "title and its content," what is the content? Is it the text of the title or the text that follows?
After that, we need to know exactly the styles used for each element.
m@rina
-
Sorry, I wasn't very clear indeed...
For example, if the document is as follows:
Chapter 1
Subtitle 1
Lorem ipsum
Subtitle 2
dolor sit
Subtitle 3
amet, consectetur
Chapter 2
Subtitle 1
adipiscing elit.
Subtitle 2
Duis bibendum
Chapter 3
...The ideal would be to have a table with
Cell 1:
"Chapter 1
Subtitle 1
Lorem ipsumSubtitle 2
dolor sit
Subtitle 3
amet, consectetur"Cell 2:
"Chapter 2
Subtitle 1
adipiscing elit.
Subtitle 2
Duis bibendum"Cell 3:
"Chapter 3
..."
etc.
For styles, what elements would you need?
The first two title styles are bold.
No style has been applied.
-
-
OK, so we change cell for each chapter?
We need to use styles, otherwise we can't do anything. The bare minimum would be for each chapter title to be in Heading 1 style.
m@rina