Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Macro to delete empty paragraph marks is also deleting section breaks

Posted on 2004-04-30
3
Medium Priority
?
511 Views
Last Modified: 2012-05-04
I am trying to get rid of extra paragraph marks in a Word document. I have a macro that will delete all the empty paragraph marks in the document, but the problem is that it also deletes section breaks if they are right above the empty paragraph mark.

Is there a way to change the macro so that only the paragraph marks are deleted, not the section breaks above them?

Here's my code:

' Delete all empty paragraphs
For Each currPara In ActiveDocument.Paragraphs
    If Len(Trim$(currPara.Range.Text)) = 1 Then
        currPara.Range.Delete
    End If
Next
0
Comment
Question by:sehenkel
[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
3 Comments
 
LVL 14

Accepted Solution

by:
Tommy Kinard earned 1200 total points
ID: 10960805
Hi sehenkel,

For Each currPara In ActiveDocument.Paragraphs
    If Len(Trim$(currPara.Range.Text)) = 1 Then
        currPara.Delete Unit:=wdCharacter, Count:=1
    End If
Next

Let me know if more help is required
dragontooth

0
 
LVL 14

Expert Comment

by:Tommy Kinard
ID: 11259655
The code I posted worked for me. No clue if it answered the question.

dragontooth

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

664 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