![]() |
Excel and Office
RAQ Getting rid of empty paragraphs in Word |
Q: I have a document which contained unwanted paragraph marks. Essentially what I want to do is to delete every line that contains only spaces and paragraph marks. Note some lines contain no spaces, just para marks, other lines have multiple spaces and then paramarks. Anyone able to tell me what the find command will be? A: This code will do the job: Sub LoseEmptyParas()
Dim p As Paragraph Dim myFlag As Boolean Dim myString As String Dim myNewString As String
For Each p In ActiveDocument.Paragraphs myString = p.Range.Text myFlag = False myNewString = Replace(myString, " ", "") If Len(myNewString) > 1 Then myFlag = True If myFlag = False Then p.Range.Delete Next
End Sub
|
|