Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-23-2024, 03:16 AM
Santiago H. Santiago H. is offline Help needed: Word macro to rearrange paragraphs Windows 10 Help needed: Word macro to rearrange paragraphs Office 2019
Novice
Help needed: Word macro to rearrange paragraphs
 
Join Date: Jul 2024
Posts: 4
Santiago H. is on a distinguished road
Default Help needed: Word macro to rearrange paragraphs

(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!
Attached Files
File Type: docx Example text_rough.docx (13.8 KB, 5 views)
File Type: docx Example text_arranged.docx (13.8 KB, 5 views)

Last edited by Santiago H.; 07-24-2024 at 02:52 AM.
Reply With Quote
  #2  
Old 07-23-2024, 04:26 PM
Aussiebear Aussiebear is offline Help needed: Word macro to rearrange paragraphs Mac OS X Help needed: Word macro to rearrange paragraphs Office 2016 for Mac
Novice
 
Join Date: Jun 2023
Posts: 7
Aussiebear is on a distinguished road
Default

Unfortunately cross posted at vbaexpress.com
Reply With Quote
  #3  
Old 07-24-2024, 02:28 AM
Santiago H. Santiago H. is offline Help needed: Word macro to rearrange paragraphs Windows 10 Help needed: Word macro to rearrange paragraphs Office 2019
Novice
Help needed: Word macro to rearrange paragraphs
 
Join Date: Jul 2024
Posts: 4
Santiago H. is on a distinguished road
Default

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!
Reply With Quote
  #4  
Old 07-24-2024, 04:02 AM
Aussiebear Aussiebear is offline Help needed: Word macro to rearrange paragraphs Mac OS X Help needed: Word macro to rearrange paragraphs Office 2016 for Mac
Novice
 
Join Date: Jun 2023
Posts: 7
Aussiebear is on a distinguished road
Default

Thank you for doing so, however did you also point out the cross post on the other forum?
Reply With Quote
  #5  
Old 07-24-2024, 07:25 AM
Santiago H. Santiago H. is offline Help needed: Word macro to rearrange paragraphs Windows 10 Help needed: Word macro to rearrange paragraphs Office 2019
Novice
Help needed: Word macro to rearrange paragraphs
 
Join Date: Jul 2024
Posts: 4
Santiago H. is on a distinguished road
Default

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.
Reply With Quote
  #6  
Old 07-25-2024, 12:41 AM
Guessed's Avatar
Guessed Guessed is offline Help needed: Word macro to rearrange paragraphs Windows 10 Help needed: Word macro to rearrange paragraphs Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #7  
Old 07-25-2024, 05:49 AM
Santiago H. Santiago H. is offline Help needed: Word macro to rearrange paragraphs Windows 10 Help needed: Word macro to rearrange paragraphs Office 2019
Novice
Help needed: Word macro to rearrange paragraphs
 
Join Date: Jul 2024
Posts: 4
Santiago H. is on a distinguished road
Default

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.
Reply With Quote
Reply



Similar Threads
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
Help needed: Word macro to rearrange paragraphs Word VBA Macro Needed to Crop & Resize Pictures 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
Help needed: Word macro to rearrange paragraphs Macro Needed to delete Unwanted paragraphs in series frustrated teacher Word VBA 1 05-02-2014 03:32 PM
Rearrange Mailing List Data gijoe985 Excel 17 08-01-2013 07:55 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:36 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