Consulting

Results 1 to 3 of 3

Thread: How to copy selected text?

  1. #1
    VBAX Newbie
    Joined
    Oct 2016
    Posts
    2
    Location

    How to copy selected text?

    Hello, everyone!

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

  2. #2
    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
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    VBAX Newbie
    Joined
    Oct 2016
    Posts
    2
    Location
    Excellent!!!
    Thank u a lot!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •