View Single Post
 
Old 09-30-2024, 04:51 PM
macropod's Avatar
macropod macropod is offline Windows 10 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