+ Reply to Thread
Results 1 to 5 of 5

Moving Contents of Line to End of Previous Line in Word 2010 doc

  1. #1
    Registered User
    Join Date
    12-07-2012
    Location
    London, England
    MS-Off Ver
    Office 2010
    Posts
    81

    Moving Contents of Line to End of Previous Line in Word 2010 doc

    I have a 200+ page Word doc that is a single column of text, converted from several 2- and 3- column docs.

    It needs several things doing to it, but the one I'm stuck on is this:

    Somewhere in the conversion process, it has happened that fairly often (it's a 200 page doc) the last word on a line has wrapped around to the next line.

    I would like that to stop happening in the first place, of course (!) but I don't know what's causing it.

    But now that it's happened, I need VBA code that will go through the doc and wherever it finds a line that's just a single word, it MUST have come from the end of the previous line, and needs to be put back there, complete with a space before it.

    Any thoughts would be greatly appreciated.
    Last edited by staggers47; 12-15-2012 at 09:17 AM.

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Moving Contents of Line to End of Previous Line in Word 2010 doc

    Hi staggers,

    You don't really need a macro - you can do the job with a wildcard Find/Replace, where:
    Find = '[^13]([! ]@[^13])'
    Replace = ' \1'
    (without the quote marks)
    Do note that this will also merge any 1-word headings with the preceding paragraphs, so be careful. I suggest selecting ranges without such headings for processing.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Registered User
    Join Date
    12-07-2012
    Location
    London, England
    MS-Off Ver
    Office 2010
    Posts
    81

    Re: Moving Contents of Line to End of Previous Line in Word 2010 doc

    Hi, sorry for the delay - was night time here!

    I do really need to do this in a macro because it's 200 and more pages. But there aren't any headings at all, luckily, because they're one of the things I stripped out. How do I incorporate this into a macro? I've never had a lot of success with find /replace in the past!
    Thanks for your help.

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Moving Contents of Line to End of Previous Line in Word 2010 doc

    I really don't see the point of writing a macro when you don't need one. The number of pages is irrelevant.

    If you're wedded to a macro, switch on the macro recorder and input a Find/Replace as described. The code thus produced in this case will be nearly as efficient as a hand-written macro. And, by the time you're finished recording the macro, the Find/Replace job will have been done ...

  5. #5
    Registered User
    Join Date
    12-07-2012
    Location
    London, England
    MS-Off Ver
    Office 2010
    Posts
    81

    Re: Moving Contents of Line to End of Previous Line in Word 2010 doc

    Point taken!

    OK, thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1