Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Jul 2003
    Location
    USA
    Posts
    728
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Macro - Loop staement (Word97/SR2)

    Hello -

    I recorded a macro that I use in a split window: it copies a line of text and pastes it into a row then deletes the line of text and stops at the next line of text to be copied/pasted.

    How can I code this so it will repeat this procedure until there are no more lines of text to be copied to the rows?

    The lines of text to be copied will not be a consistent number.

    The code I now have is:

    Sub TableCopyTextToRow()

    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
    Selection.Copy
    ActiveWindow.ActivePane.Next.Activate
    Selection.Paste
    Selection.MoveDown Unit:=wdLine, Count:=1
    ActiveWindow.ActivePane.Next.Activate
    Selection.Delete
    Selection.MoveDown Unit:=wdLine, Count:=1
    End Sub

    I guess all the lines to be copied to the table could, somehow be selected/pasted at once rather than line by line, but that is also beyond me.

    Thank you very much for your help.
    ACM

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Macro - Loop staement (Word97/SR2)

    It sounds like you are doing this a long way around. Is there a reason you need to do this on a line by line basis.

    Can you just select the text in the first document and choose Tables > Convert > Text to Table?

    Once this is done you can cut the whole table and paste it to the other pane.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    5 Star Lounger
    Join Date
    Jul 2003
    Location
    USA
    Posts
    728
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Re: Macro - Loop staement (Word97/SR2)

    Andrew -

    Thank you. The obvious sometimes get buried.....

    ACM

Posting Permissions

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