Solved

Macro to delete empty paragraph marks is also deleting section breaks

Posted on 2004-04-30
3
489 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
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
Tommy Kinard earned 300 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

705 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

11 Experts available now in Live!

Get 1:1 Help Now