• copy & paste macro doesn't work

    Author
    Topic
    #464814

    Office 2007:
    This macro I use in Word is supposed to copy to the end of the line, 5 lines in succession, then cursor to the next line (if any).
    Purpose-To put address info to the Office Clipboard, where I can easily paste into Excel cells.

    Sub FiveLineCopy()

    ‘ FiveLineCopy Macro


    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    Selection.Copy
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    Selection.Copy
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    Selection.Copy
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    Selection.Copy
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    Selection.Copy
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    End Sub

    Viewing 3 reply threads
    Author
    Replies
    • #1191596

      What exactly goes wrong? When I run your code in Word 2002, it does put 5 items on the Office clipboard, and when I switch to Excel, these are available to be pasted.

      • #1191599

        I see the cursor flicker down the five lines, but nothing is copied. The clipboard is available and not full.

        • #1191601

          I hope that someone who has Word 2007 (I don’t) can help you.

        • #1191605

          It works perfectly for me under Office 2007 SP2.
          I can watch it copy 5 lines to the clipboard, one after the other.

    • #1191657

      Could it be something about your document? Does the problem occur in all documents?

    • #1191838

      I’ve attached an example of a list where the macro doesn’t work. The problem seems to change every day. Today, it moves down but only copies the fifth line.

      • #1191875

        I’ve attached an example of a list where the macro doesn’t work. The problem seems to change every day. Today, it moves down but only copies the fifth line.

        I can’t see anything wrong with this document.

        I displayed the clipboard and cleared it
        I placed the cursor immediately before the line “UO Office of Admissions”
        I ran your macro and captured the attached screen shot, showing 5 lines on the clipboard.

    • #1192032

      Thanks for checking this out. The problem appears to be the clipboard itself, and I have posted about that separately.

      • #1192574

        Thanks for checking this out. The problem appears to be the clipboard itself, and I have posted about that separately.

        I don’t know about the clipboard problem, but I did code something similar, to create a table, and I forgot to put the cursor at the beginning of the line after each carriage return. I don’t know the code but usually use the “record macro” command to provide the code and doctor it from there.

        HTH.

        Paul

    Viewing 3 reply threads
    Reply To: copy & paste macro doesn't work

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: