Sub DeleteConsecutiveEmptyParagraphs() paraCount = ActiveDocument.Paragraphs.Count idx = 2 Do While idx < paraCount forward_Paragraph = Replace(Replace(ActiveDocument.Paragraphs(idx - 1).Range.Text, " ", ""), vbTab, "") now_Paragraph = Replace(Replace(ActiveDocument.Paragraphs(idx).Range.Text, " ", ""), vbTab, "") ' 这里可以判断长度是否为1或者通过replace函数删除段落符号(vbCr)(replace(text,vbCr,""))然后判断长度为0来实现。 If Len(now_Paragraph) = 1 And Len(forward_Paragraph) = 1 Then ActiveDocument.Paragraphs(idx).Range.Delete Else idx = idx + 1 End If paraCount = ActiveDocument.Paragraphs.Count Loop End Sub
标签:空行,Paragraph,删除,idx,paraCount,Replace,ActiveDocument,连续,Paragraphs From: https://www.cnblogs.com/love-DanDan/p/18229265