![]() |
#1
|
|||
|
|||
![]()
(I have also posted this here: Word macro to rearrange paragraphs)
Hello! I am having trouble finding the right VBA code for the following: I work with draft documents on Word that have several consecutive paragraphs. At the end of the document, there are several more individual lines with time stamps. The lines with the time stamps can look like this: - There is a time stamp followed by some italic text. This line forms a section. - There is a time stamp followed by some text in bold. After the bold text, there is a line of italic text. These two lines form a section that is independent of the other section. So each time stamp initiates its own time stamp section. The next time stamp section starts with the next time stamp. You can see an example of how this document can look like in the Word doc attached ('Example text_rough'). The words 'Text' are meant as a placeholder for actual sentences. The 'XX:XX' are the time stamps. I highlighted the lines with the time stamps in yellow so you can distinguish. The actual documents I work with don't have yellow highlights. I then rearrange the paragraphs so that each time stamp section introduces two paragraphs. So first you have time stamp section 1 and then paragraphs 1 and 2 below. Then you have time stamp section 2 and then paragraphs 3 and 4 below. This continues until the last time stamp is at the end. You can see the new arrangement in the attached Word doc called 'Example text_arranged'. What I want is to have a macro that automates these steps, rearranging the time stamp sections and the paragraph sections. The documents I work with can have different lengths of paragraphs and the time stamp sections can also look different than in the docs attached. Sometimes there are several consecutive time stamp sections that have only one line, sometimes there are also several consecutive time stamp sections that have more than one line. But what always stays the same is that one time stamp section ends when the next time stamp shows up, as this next time stamp initiates the next time stamp section. Thank you for helping me out on this. I think it is a very specific issue but I can imagine that there is a way to automate this process. I tried to find a way using ChatGPT but the solutions it offered weren't working as I often got error messages. Thanks! Last edited by Santiago H.; 07-24-2024 at 02:52 AM. |
#2
|
|||
|
|||
![]()
Unfortunately cross posted at vbaexpress.com
|
#3
|
|||
|
|||
![]()
Hello Aussiebear,
I understand it's best to cross-reference the two threads so I edited the original post on this forum by adding a link on the very top. I hope this is alright. Thank you for pointing this out! |
#4
|
|||
|
|||
![]()
Thank you for doing so, however did you also point out the cross post on the other forum?
|
#5
|
|||
|
|||
![]()
I have added a comment with the link. I would like to add it to the post itself, but it doesn't seem to be possible.
|
#6
|
||||
|
||||
![]()
The link you posted to the other forum isn't working so I don't know if the problem is the link or the site itself.
You've made a dummy file as a sample and it may or may not relate to the real life files you deal with so I'm not going to waste time with code that might work. But I will describe a non-coded way to approach this problem - this non-coded method could actually be a similar process that a macro could work. 1. Select the text at the top (before the timestamps begin) and convert it to a table, separated at paragraphs and 2 columns. Then insert 2 columns to the left. 2. With the timestamped text, you could do a similar method although you will need to first insert empty paragraphs where there isn't a second paragraph under a timestamp. 3. Then you could paste the two columns from the timestamps into the extra two columns you added in Step 1. Assuming all that lines up correctly, you can convert the table back to text and the job is done.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#7
|
|||
|
|||
![]()
Thank you! Your suggestion with converting the text to a table is very helpful and bringing me closer to what I want. I'm seeing if I can translate these steps into a macro code. I feel I'm getting there.
|
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Need help with word macro to duplicate paragraphs in word document | baidu0021 | Word VBA | 4 | 07-06-2022 04:58 AM |
![]() |
Alex Cheng | Word VBA | 5 | 10-04-2021 11:15 AM |
Macro Needed to delete Unwanted paragraphs within a table. | frustrated teacher | Word VBA | 0 | 06-05-2015 12:47 PM |
![]() |
frustrated teacher | Word VBA | 1 | 05-02-2014 03:32 PM |
Rearrange Mailing List Data | gijoe985 | Excel | 17 | 08-01-2013 07:55 AM |