• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 657
  • Last Modified:

Delete blank pagraphs in between tables using search and replace functionality

Dear Experts:

How can I delete blank paragraphs in between tables using the search and replace functionality.

The search for ^p and replace it with nothing approach does not seem to work.

I have attached a sample file for your convenience.

The result of this 'search and replace operation' or a VBA code should be that there is just one table left.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
Delete-Paragraph-Marks-Between-T.doc
0
AndreasHermle
Asked:
AndreasHermle
1 Solution
 
GrahamSkanRetiredCommented:
Hi Andreas,

It seems that the Find and Replace has been designed not to delete paragraphs in the case that they are keeping tables separated.
You can do it with a macro:
Sub JoinTables()
    Dim rng As Range
    
     Set rng = ActiveDocument.Range
     With rng.Find
        .Text = "^p"
        Do While .Execute
            If ActiveDocument.Range.End - rng.End < 2 Then
                Exit Do
            Else
                rng.Delete
            End If
        Loop
    End With
End Sub

Open in new window

0
 
AndreasHermleAuthor Commented:
Hi Graham,

wow, great coding, Graham! Thank you very much for your professional help.

Regards, Andreas
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now