|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
楼主,如果你说的“删除空段”是指表格内的空段,则上面《表格处理》宏已经包括了!还请试用下面的宏:
- Sub 删除空行()
- Dim i As Paragraph
- For Each i In ActiveDocument.Paragraphs
- If Asc(i.Range) = 13 Then i.Range.Delete
- Next
- End Sub
复制代码- Sub 删除表格空行()
- Dim t As Table, s As Long, r As Row
- If Selection.Information(wdWithInTable) = True Then s = 1
- For Each t In ActiveDocument.Tables
- If s = 1 Then Set t = Selection.Tables(1)
- With t
- If .Uniform = False Then GoTo sk
- With .Range
- .Rows.WrapAroundText = False
- .Next.InsertParagraphBefore
- .Find.Execute "[^13^l]", , , 1, , , , , , "^p", 2
- End With
- .Select
- With Selection
- .MoveEnd
- CommandBars.FindControl(ID:=122).Execute
- .Characters.Last.Delete
- End With
- For Each r In .Rows
- If Len(Replace(Replace(r.Range.Text, vbCr, ""), Chr(7), "")) = 0 Then r.Delete
- Next
- End With
- If s = 1 Then Exit For
- sk:
- Next
- End Sub
复制代码 |
|