Solved

Replace Redundant Paragraph Marks

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
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.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

776 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