Results 1 to 10 of 10
  1. #1
    2 Star Lounger
    Join Date
    Jan 2008
    Location
    Wheaton, Illinois, USA
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    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.

  3. #3
    2 Star Lounger
    Join Date
    Jan 2008
    Location
    Wheaton, Illinois, USA
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I see the cursor flicker down the five lines, but nothing is copied. The clipboard is available and not full.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    I hope that someone who has Word 2007 (I don't) can help you.

  5. #5
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts
    It works perfectly for me under Office 2007 SP2.
    I can watch it copy 5 lines to the clipboard, one after the other.

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Could it be something about your document? Does the problem occur in all documents?

  7. #7
    2 Star Lounger
    Join Date
    Jan 2008
    Location
    Wheaton, Illinois, USA
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Attached Files Attached Files

  8. #8
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by halfmybrain View Post
    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.

    [attachment=87188:Clipboard.png]
    Attached Images Attached Images

  9. #9
    2 Star Lounger
    Join Date
    Jan 2008
    Location
    Wheaton, Illinois, USA
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for checking this out. The problem appears to be the clipboard itself, and I have posted about that separately.

  10. #10
    New Lounger
    Join Date
    Dec 2009
    Location
    Sheffield
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by halfmybrain View Post
    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

Posting Permissions

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