Results 1 to 4 of 4
  1. #1
    3 Star Lounger Omega3's Avatar
    Join Date
    Jan 2004
    Location
    Los Angeles, California, USA
    Posts
    343
    Thanks
    2
    Thanked 1 Time in 1 Post

    Condense paragraphs but keep real paragraphs (2003)

    I am trying to create a macro that will replace all paragraph marks in the entire document with nothing. This would force all lines ending with a paragraph mark to become one paragraph. But I want to keep the real paragraph, those that have two paragraph marks side by side. For instance,

    Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1
    Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1
    Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1
    Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1

    Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2
    Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2
    Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2

    Would become

    Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1

    Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2

    Using the replace menu item would merge them all together into one big paragraph. The key would be to recognize the two paragraph markers side by side and not replace those. Is there a way accomplish this?
    You know it's time to diet when you push away from the table and the table moves.

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

    Re: Condense paragraphs but keep real paragraphs (2003)

    You can do this without a macro:
    1) Replace all <code>^p^p</code> (2 consecutive paragraph marks) with <code>@@@@</code> (a meaningless placeholder)
    2) Replace all <code>^p</code> with a space.
    3) Replace all <code>@@@@</code> with <code>^p</code>

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

    Re: Condense paragraphs but keep real paragraphs (2003)

    And here is a macro version:
    <code>
    Sub ReplaceParas()
    With ActiveDocument.Content.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .MatchWildcards = False
    .Execute FindText:="^p^p", ReplaceWith:="@@@@", Replace:=wdReplaceAll
    .Execute FindText:="^p", ReplaceWith:=" ", Replace:=wdReplaceAll
    .Execute FindText:=@@@@", ReplaceWith:="^p", Replace:=wdReplaceAll
    End With
    End Sub
    </code>
    You'll note that in both my replies, two paragraph marks are replaced with a single one. This is deliberate. You should create white space between paragraphs by setting the Space Before and/or Space After of the style you're using, not by using two paragraph marks.

  4. #4
    3 Star Lounger Omega3's Avatar
    Join Date
    Jan 2004
    Location
    Los Angeles, California, USA
    Posts
    343
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Condense paragraphs but keep real paragraphs (2003)

    Thank you Hans! The macro will be quicker to use with a shortcut key. This will save us a lot of formating time. I can insert the paragraph spacing so it's formatted without the need for two paragraph markers. I appreciate your help in putting the macro together!
    You know it's time to diet when you push away from the table and the table moves.

Posting Permissions

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