• Condense paragraphs but keep real paragraphs (2003)

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Condense paragraphs but keep real paragraphs (2003)

    Author
    Topic
    #450986

    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?

    Viewing 1 reply thread
    Author
    Replies
    • #1109162

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

    • #1109166

      And here is a macro version:

      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

      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.

      • #1109183

        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!

    Viewing 1 reply thread
    Reply To: Condense paragraphs but keep real paragraphs (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: