Link to home
Start Free TrialLog in
Avatar of FaheemAhmadGul
FaheemAhmadGulFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Macro To Remove Duplicate Paragraphs from a Word Document

I have word documents that (due to some reason) end up having duplicate (or even triplicate) entries of some paragraphs. For example paragraph 1, 2 and 3 may be hundred percent identical. Similarly paragraph 4 and 5 may be identical (so forth and so on).
I would like to have a macro that will (starting from the top of the document) will compare each of the two consecutive paragraphs in the document and will delete one of the two paragraphs if it finds that those two paragraphs are identical. For example it will first compare Para 1 and 2 and if it finds that they are identical it will delete Para 1. It will then compare Para 2 (which would, after deletion of Para 1, would have now become Para 1) with Para 3 and will delete Para 2 if it finds that Para 2 is identical to Para 3. It will then compare Para 3 and Para 4 and so forth and so on. The end result of this will be that all duplicate or triplicate entries of identical Paragraphs would have been removed by the Macro.
To make my Problem easier to understand I attach a file (named File with Duplicate Entries) with duplicate entries on which I would like to run my planned macro. I also attach another file (named File without Duplicate Entries) which is how I would expect my first File (with Duplicate Entries) to look like after running the planned Macro.  
Thank you for your help in anticipation
File-With-Duplicate-Entries.doc
File-Without-Duplicate-Entries.doc
ASKER CERTIFIED SOLUTION
Avatar of irudyk
irudyk
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of FaheemAhmadGul

ASKER

Brilliant!  This worked perfectly. I am extremely grateful. Regards - Faheem
Brilliant!  This worked perfectly. I am extremely grateful. Regards - Faheem