实现代码
Sub DeleteTableCarriageReturns()Dim oTbl As TableDim oCell As cellDim oRng As Range' 遍历文档中所有表格For Each oTbl In ActiveDocument.Tables' 遍历表格中的每个单元格For Each oCell In oTbl.Range.CellsSet oRng = oCell.RangeoRng.End = oRng.End - 1 ' 排除单元格结束标记' 在单元格范围内执行替换With oRng.Find.Text = "^p" ' 匹配段落标记.Replacement.Text = "".Forward = True.Wrap = wdFindStop ' 仅在当前范围操作.Execute Replace:=wdReplaceAllEnd WithNext oCellNext oTbl
End Sub
代码使用方法见批量处理word里面表格的空白行