Solved

Replace Redundant Paragraph Marks

Posted on 2008-06-09
2
449 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

751 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