Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #8  
Old 02-03-2015, 04:30 PM
macropod's Avatar
macropod macropod is offline VBA to solve duplicate words in one line Windows 7 64bit VBA to solve duplicate words in one line Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,523
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try the following macro - it doesn't find 'duplicates' where one word uses capitals and the other doesn't, but it should deal with all the rest.
Code:
Sub Demo()
Dim i As Long
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "(<[A-Za-z]@>)([!^13]@)<\1>"
    .Replacement.Text = "\1\2"
    .Format = False
    .Forward = True
    .Wrap = wdFindContinue
    .MatchWildcards = True
  End With
  Do While i <> Len(.Text)
    i = Len(.Text)
    .Find.Execute Replace:=wdReplaceAll
  Loop
  With .Find
    .Text = "[ ]{2,}"
    .Replacement.Text = " "
    .Execute Replace:=wdReplaceAll
  End With
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to solve duplicate words in one line Word 2013 words cut at end of line and other decalations Alex.g Word 4 06-20-2022 07:50 PM
VBA to solve duplicate words in one line How to find and delete duplicate words in doc cinvest Word 1 09-29-2014 08:34 PM
Can anyone solve this problem? ChrisHoppyBot Office 0 02-20-2013 01:08 AM
Creating different spacing for words on the same line Jenjen80 Word 1 08-12-2010 05:52 AM
please help me to solve this issue...... middo1022 PowerPoint 0 08-28-2009 04:47 AM

Other Forums: Access Forums

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