The macro I am trying to write is similar to my previous thread "Remove Blank Paragraph before Next Page Section Break?"
This time, I am trying to remove blank paragraphs at the start and at the end of table cells. I used the final macro from my prevous thread as the starting point and came up with the following code. I don't get any errors, but the paragraph marks aren't being deleted either.
Any help you can give is greatly appreciated!
Cheryl
This time, I am trying to remove blank paragraphs at the start and at the end of table cells. I used the final macro from my prevous thread as the starting point and came up with the following code. I don't get any errors, but the paragraph marks aren't being deleted either.
Code:
Dim intTableCount As Integer
Dim intTable As Integer
Dim currRow As Row
Dim currCell As Cell
Dim intCharCount As Long
Dim intChar As Long
' Count number of tables in the document
intTableCount = ActiveDocument.Tables.Count
' In each table:
For intTable = 1 To intTableCount
' Check each cell in each row of the table
For Each currRow In ActiveDocument.Tables(intTable)
For Each currCell In currRow.Cells
' Count number of characters in the cell
intCharCount = .Range.Characters(intChar).Count
' STEP 1: Starting with the FIRST character in the cell,
' check each character to see if it is a paragraph mark
For intChar = 1 To intCharCount Step 1
' If the character is a paragraph mark, need to delete it
If .Range.Characters(intChar) = vbCr Then
.Range.Characters(intChar).Delete
' If the character is not a paragraph mark, break out of
' the loop and check the next cell
ElseIf .Range.Characters(intChar) <> vbCr Then
Exit For
End If
Next
' STEP 2: Starting with the LAST character in the cell,
' check each character to see if it is a paragraph mark
For intChar = intCharCount To 1 Step -1
' If the character is a paragraph mark, need to delete it
If .Range.Characters(intChar) = vbCr Then
.Range.Characters(intChar).Delete
' If the character is not a paragraph mark, break out of
' the loop and check the next cell
ElseIf .Range.Characters(intChar) <> vbCr Then
Exit For
End If
Next
Next currRow
Next intTable
Any help you can give is greatly appreciated!
Cheryl