|
楼主,因我家里电脑上未安装OFFICE2007及以上兼容包(也不想安),故我在WORD2003上试验的代码,如有错误,仅供参考吧!
- Sub delEmptyLine()
- 'Sub 删除手动换行符和假段落标记()-----全部替换(相当于WORD中的“替换”操作)
- ActiveDocument.Content.Find.Execute FindText:="^l", replacewith:="^p", Replace:=wdReplaceAll
- ActiveDocument.Content.Find.Execute FindText:="^13", replacewith:="^p", Replace:=wdReplaceAll
- '将全角空格替换为段落标记
- ActiveDocument.Content.Find.Execute FindText:=Chr(-24159), replacewith:="^p", Replace:=wdReplaceAll
- 'Sub 删除空行()----循环遍历段落法
- Dim i As Paragraph
- For Each i In ActiveDocument.Paragraphs
- If Len(i.Range) = 1 Then i.Range.Delete
- Next
- 'Sub 删除表格空白行()
- Dim tb As Table, r As Row
- With ActiveDocument
- For Each tb In .Tables
- For Each r In tb.Rows
- r.Range.Find.Execute FindText:="^l", replacewith:="^p", Replace:=wdReplaceAll
- r.Range.Find.Execute FindText:=" ", replacewith:="", Replace:=wdReplaceAll
- r.Range.Find.Execute FindText:="^w", replacewith:="", Replace:=wdReplaceAll
- If Len(Replace(Replace(r.Range.Text, vbCr, ""), Chr(7), "")) = 0 Then r.Delete
- Next
- Next
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|