Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 09-30-2024, 04:51 PM
macropod's Avatar
macropod macropod is offline Duplicate selected words for continuous and individual selection Windows 10 Duplicate selected words for continuous and individual selection Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,465
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, which works even if you don't have whole words selected and preserves the original formatting:
Code:
Sub DuplicateSelectedWords()
Dim Rng As Range
With Selection
  If .Type = wdSelectionIP Then
    MsgBox "Select the text first", vbCritical
    Exit Sub
  End If
  Set Rng = ActiveDocument.Range(.Words.First.Start, .Words.Last.End)
End With
With Rng.Duplicate
  .Collapse wdCollapseEnd
  .FormattedText = Rng.FormattedText
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplicate selected words for continuous and individual selection Removing a duplicate words ranjan Word VBA 7 08-26-2021 02:17 AM
Page numbers not following. All sections continuous, link to previous selected. ClaireP Word 4 07-07-2020 08:12 AM
Duplicate selected words for continuous and individual selection VBA to solve duplicate words in one line Bookmaster Word VBA 7 02-03-2015 04:30 PM
Duplicate selected words for continuous and individual selection How to find and delete duplicate words in doc cinvest Word 1 09-29-2014 08:34 PM
Why Words doesn’t show the style of the selected words automatically???? Jamal NUMAN Word 0 04-14-2011 03:20 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:12 PM.


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