Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Mar 2010
    Location
    Texas
    Posts
    54
    Thanks
    9
    Thanked 0 Times in 0 Posts
    For Find and Replace, it always puts an extra character after the last line. For example, using the three lines below:

    Line1
    Line2
    Line3

    The Find/Replace values of Find: ^13 and Replace with *^13 always inserts an extra CRLF after the last line:

    Line1*
    Line2*
    Line3*


    How can I not have the extra character add?

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Try a wildcard Find/Replace with:
    Find = ([!^13]{1,})
    Replace = \1*
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    Star Lounger
    Join Date
    Mar 2010
    Location
    Texas
    Posts
    54
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Excellent. Works like a charm.

    Out of curiosity though, why does the original search add an extra line only to the last line?

  4. #4
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Probably because all documents must finish with a paragraph mark and for a moment in time your search and replace removes this paragraph mark and Word stops the document corrupting by adding one in for you. Note that your search and replace finds paragraph marks are replaces them with pseudo-paragraph marks. You should have replaced the ^13 with a ^p rather than ^13. Hint: Check your paragraph count before and after replacing with ^13.

    The better question would be why does Macropod's solution work. He very cunningly searches for everything except a ^13 and adds a star AFTER it. This avoids actually replacing the paragraph marks at all. This is also very clever because ^13 is actually different to a ^p and you can't search for ^p when wildcards is turned on (but you can use them in the replace box.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  5. #5
    WS Lounge VIP
    Join Date
    Mar 2006
    Location
    Maryland, USA
    Posts
    690
    Thanks
    17
    Thanked 66 Times in 56 Posts
    Macropod's code replaces everything in the line but the ^13. So it doesn't really change the ^p to the pseudo paragraph mark (^13). That's why it works.

    Pam
    Pam Caswell

Posting Permissions

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