Solved

Replace Redundant Paragraph Marks

Posted on 2008-06-09
2
437 Views
Last Modified: 2012-06-21
Dear Experts:
Below macro deletes any redudant paragraph marks in a document. It is running just fine but it strangely does not delete two consecutive blank paragraphs that are located directly before a table.

Example:

text, text, text, paragraph mark
blank paragraph mark
blank paragraph mark
Table

Any idea why this is so?

Help is apprecitated. Thank you very much in advance. Regards, Andreas

Sub ReplaceRedundantParagraphMarks()

Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "^0013{2;}"
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
   
    Selection.Find.Execute Replace:=wdReplaceAll
   
End Sub
0
Comment
Question by:AndreasHermle
2 Comments
 
LVL 12

Accepted Solution

by:
geneus earned 500 total points
ID: 21750986
Usure why this does not work but the code below will remove ALL empty paragraph marks.
Sub RemoveBlankPara()

    'Delete any Blank Paragraphs in the document

    

    Dim opara As Word.Paragraph

    

    For Each opara In ActiveDocument.Paragraphs

        If opara.Range.Text = Chr(13) Then

        opara.Range.Delete

        End If

    Next

    

End Sub

Open in new window

0
 

Author Comment

by:AndreasHermle
ID: 21774081
Dear geneus:

thank you very much. It works as desired.
Regards, Andreas
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now