Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    4 Star Lounger
    Join Date
    Mar 2001
    Location
    Bismarck, ND, USA
    Posts
    451
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Find & Replace Hard Returns (2003, SP1)

    I need to replace any hard returns between a page break and a "space". Most of the time there are 9 hard returns, but every once in a while there will be a different number, and it's not consistant.

    TIA
    egghead

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Find & Replace Hard Returns (2003, SP1)

    You want to replace a variable number of paragraph marks, when the set starts at the top of a page, with something. Is that right?

    The Find/Replace dialog is unaware of soft page breaks, so unless there is a hard page break to search for, you probably will need to write some VBA code. One approach might be to the go the top of the next page, check for an empty paragraph, select forward until the paragraphs stop being empty, and then type over the select with the desired new text. Does that sound like it would work?

  3. #3
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    120
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find & Replace Hard Returns (2003, SP1)

    Does this document have any paragraph/style formatting applied? If not then you can use find/replace with wildcards as follows:
    1. Use find/replace to change all hard returns to soft returns i.e. find what: ^p replace with: ^l
    2. Use find/replace with wildcards switched on and in the find what box enter ^m^l@<space> (<space> is simply a space character) and in the Replace box put whatever you want - maybe just the space character or perhaps the page break and the space if you're just wanting to get rid of the hard returns.
    3. With wildcards turned off, reverse step 1, i.e. change all soft returns to hard returns.

    If there are any soft returns in the document before you start this then you will need to change all of those first to some string that does not appear in the doc and then change that string back to a soft return as the last step.

    Because you're zapping all of the hard returns in the document (even though you resore them later) you'll lose any associated paragraph formatting - in which case the only option you have is to resort to VBA

  4. #4
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Find & Replace Hard Returns (2003, SP1)

    If the page breaks you're talking about are manual page breaks, the following Find/Replace may work for you without the need to change hard returns to soft returns. In the Find box, put "^12^13@ " (don't miss the final space) and in the Replace box put "^12 " (again, don't miss the final space), and be sure to check "Use wildcards."

    In case you're not familiar with wildcard searches, the "@" means any (consecutive) number of the preceding character. So, since "^13" is a hard return, "^13@" means "any number of hard returns in a row."

    Final note: Unfortunately, "^12" will find section breaks as well as manual page breaks, so if you don't want to do the replacement if the target is at the start of a section, you'll have to do the replace one at a time (rather than as a Replace All), so you can avoid replacing at the start of sections.

  5. #5
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Find & Replace Hard Returns (2003, SP1)

    As an added note, here's a <!post=Star Post,421558>Star Post<!/post> on finding & replacing special characters, and here's a nice MVPs article on the same subject.

  6. #6
    4 Star Lounger
    Join Date
    Mar 2001
    Location
    Bismarck, ND, USA
    Posts
    451
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find & Replace Hard Returns (2003, SP1)

    That's exactly what I want to do, except that I don't want to replace the hard returns with anything. There's a manual page break, followed by a number of hard returns (normally 9), but sometimes more. There are additional hard returns within the text on the page, so I don't want to lose those or the formatting. Only if they are a group of hard returns after the manual page break.

    Thanks!
    egghead

  7. #7
    4 Star Lounger
    Join Date
    Mar 2001
    Location
    Bismarck, ND, USA
    Posts
    451
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find & Replace Hard Returns (2003, SP1)

    Thanks for the help. I have tried your suggestion and am getting the message that the search item was not found. The page breaks are manual page breaks. Then they are followed by nine hard returns, usually, but the amount isn't always consistent. The document has one section.

    Here's what I used: ^12^13@ (including a space at the end)
    Use wildcards is checked.

    I'm just typing a space into the replace box.

    Can you see what I'm doing incorrectly? Thanks.
    egghead

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Find & Replace Hard Returns (2003, SP1)

    If you show non-printing characters, how is the space displayed? A normal space is a dot, special spaces such as the non-breaking space as a degree symbol. You could try

    ^12^13@^0160

    in the Find What box.

  9. #9
    4 Star Lounger
    Join Date
    Mar 2001
    Location
    Bismarck, ND, USA
    Posts
    451
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find & Replace Hard Returns (2003, SP1)

    The spaces appear as normal, black circles. However, when I try what you suggested, it says the search item is not found.
    egghead

  10. #10
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Find & Replace Hard Returns (2003, SP1)

    I'm thinking maybe I was a little misled by your original post in terms of the consecutive hard returns being followed by a space character. I included a space at the end of my Find string on that assumption. If you're looking to replace consecutive hard returns after a manual page break regardless of whether a space character is (already) the next character, just remove the final space from my suggested Find string.

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Find & Replace Hard Returns (2003, SP1)

    Could you attach a stripped down copy of such a document? You can remove almost all text, just leave a hard page break followed by some returns and a space.

  12. #12
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Find & Replace Hard Returns (2003, SP1)

    Another thing to check would be to make sure there's no Formatting in your search -- i.e., click the More button and then click the No Formatting button (if it isn't greyed out).

  13. #13
    3 Star Lounger
    Join Date
    Apr 2004
    Location
    Boston, Massachusetts, USA
    Posts
    389
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find & Replace Hard Returns (2003, SP1)

    You're sure there's a space after the final paragraph break? The pattern suggested works fine in a sample doc I created (see attached screen shot). Posting a sample file for us to look at would help quite a bit.
    Attached Images Attached Images

  14. #14
    4 Star Lounger
    Join Date
    Mar 2001
    Location
    Bismarck, ND, USA
    Posts
    451
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find & Replace Hard Returns (2003, SP1)

    Here's a stripped version of the file. Your input is appreciated.
    Attached Files Attached Files
    egghead

  15. #15
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Find & Replace Hard Returns (2003, SP1)

    You have attached some kind of text file, not a Word document.

Page 1 of 2 12 LastLast

Posting Permissions

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