Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Replace Redundant Paragraph Marks

Posted on 2008-06-09
2
Medium Priority
?
454 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Suggested Courses

971 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