Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-31-2018, 11:14 AM
moorea21 moorea21 is offline delete 1 or 2 adjacent duplicate paragraphs, macro Windows 7 64bit delete 1 or 2 adjacent duplicate paragraphs, macro Office 2010 64bit
Novice
delete 1 or 2 adjacent duplicate paragraphs, macro
 
Join Date: Jun 2018
Posts: 8
moorea21 is on a distinguished road
Default delete 1 or 2 adjacent duplicate paragraphs, macro

I am hoping to be able to write a macro that deletes a paragraph if it follows a duplicate paragraph. I have written a macro to delete all the unwanted tags etc from an srt file, and just leave the subtitle's words. What generally happens is that the resulting files have 3 duplicate paragraphs in a row, but not exclusively. The subtitles are in Russian cyrillic, so none of the online srt to text converters want to know.
I re-wrote a macro I found on the net (always a bad start, I know) and surprise surprise, it doesnt work...




Sub DeleteDuplicateParagraphsInSRTsOnly()


Dim p1 As Paragraph
Dim p2 As Paragraph
Dim p3 As Paragraph


For Each p1 In ActiveDocument.Paragraphs
For Each p3 In ActiveDocument.Paragraphs
If p1.Range.Text = p3.Range.Text Then p3.Range.Delete
For Each p2 In ActiveDocument.Paragraphs
If p1.Range.Text = p2.Range.Text Then p2.Range.Delete
Next p1

End Sub


Obviously I don't know what I'm doing. I had hoped it would just read the 3rd paragraph, compare it to the first, delete if identical, then apply the same rule to the 2nd paragraph, then move on to the compare what was originally the 4th paragraph with the 7th, etc.


What am I miossing in order to get this to work?


Thanks
Reply With Quote
 

Tags
duplicates, macro



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Needed to delete Unwanted paragraphs within a table. frustrated teacher Word VBA 0 06-05-2015 12:47 PM
delete 1 or 2 adjacent duplicate paragraphs, macro How to delete the two non-adjacent rows in a table Word beginner Word 2 01-05-2015 05:47 AM
delete 1 or 2 adjacent duplicate paragraphs, macro Macro Needed to delete Unwanted paragraphs in series frustrated teacher Word VBA 1 05-02-2014 03:32 PM
delete 1 or 2 adjacent duplicate paragraphs, macro Macro to Delete Duplicate Rows and Retain Unique Value expert4knowledge Excel Programming 1 02-17-2014 08:02 PM
delete 1 or 2 adjacent duplicate paragraphs, macro Word Macro to find and delete rows that contain adjacent cells containing "." AlexanderJohnWilley Word VBA 7 11-08-2012 10:15 AM

Other Forums: Access Forums

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