PDA

View Full Version : How to copy selected text?



Ant6729
10-27-2016, 05:33 AM
Hello, everyone!

I woild like to see macro to copy selected text to the end of the document.\
Is this possible?

gmayor
10-28-2016, 12:19 AM
That's fairly simple, though I assume you mean the 'highlighted' text and not 'selected' text.

Sub CopyTextatEnd()
Dim oRng As Range
Dim sText As String: sText = ""
Set oRng = ActiveDocument.Range
With oRng.Find
.Highlight = True
Do While .Execute
sText = sText & vbCr & oRng.Text
oRng.Collapse 0
Loop
End With
ActiveDocument.Range.InsertAfter sText
lbl_Exit:
Set oRng = Nothing
Exit Sub
End Sub

Ant6729
10-28-2016, 05:10 AM
Excellent!!!
Thank u a lot!!