Solved

Replace Redundant Paragraph Marks

Posted on 2008-06-09
2
439 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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 …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

929 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

10 Experts available now in Live!

Get 1:1 Help Now