Hi,
I have 3 paragraphs in a table cell. Each paragraph separated by a blank
line. I'd like to delete the blank line so that all paragraphs aren't separated
anymore.
Example:
line1 sentences paragraph
line2 sentences paragraph
line3 sentences paragraph
Wanted:
line1 sentences paragraph
line2 sentences paragraph
line3 sentences paragraph
Code so far:
For tblIdx = 1 To ActiveDocument.Tables.Count
Set theTable = ActiveDocument.Tables(tblIdx)
If Mid(theTable.Cell(2, 2).Range.Text, 1, 23) = "Scenario and Conditions" Then
With Selection.Find
.Text = "^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End If
Next
Set theTable = ActiveDocument.Tables(tblIdx)
If Mid(theTable.Cell(2, 2).Range.Text, 1, 23) = "Scenario and Conditions" Then
With Selection.Find
.Text = "^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End If
Next
Would anyone know how to delete the blank lines in all of table
cells
Please help me! Thank you so muchh...
tsoetant

delete blank line in table cell
mattdawg
Sub DeleteEmptyParagraphs()
Dim numPara As Integer
Dim counter As Integer
Dim rng As Range
Dim tblCell As Cell
Dim aTable As Table
For Each aTable In ActiveDocument.Tables 'for each table in the document
For Each tblCell In aTable.Range.Cells 'for each cell in the table
Set rng = tblCell.Range 'range is current cell
numPara = rng.Paragraphs.Count
For counter = numPara To 1 Step -1 'for each paragraph in the cell
If Len(rng.Paragraphs(counter).Range.Text) <= 1 Then
rng.Paragraphs(counter).Range.Delete
End If
Next counter
Next tblCell
Next aTable
End Sub