|
楼主,我把你的两个问题搞混了,所以,来一个综合的宏(但未搞定左缩进为0,自己全选/格式/段落/左缩进设置为0吧),差强人意,对付着用吧!
- Sub test()
- On Error Resume Next
- '删除手动换行符和假段落标记
- 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
- '删除所有表格每个单元格中的回车符
- Dim t As Table, c As Cell
- For Each t In ActiveDocument.Tables
- With t
- With .Rows
- .WrapAroundText = False '取消文字环绕
- .Alignment = wdAlignRowLeft '左对齐
- .LeftIndent = CentimetersToPoints(0) '左缩进 0 厘米
- .HeightRule = wdRowHeightAtLeast '表格行高(最小值)
- .Height = CentimetersToPoints(0.7) '表格行高(0.7 厘米)
- End With
- With .Range
- With .Font '字体格式
- .Name = "Times New Roman"
- .Size = 12
- .Kerning = 0
- .DisableCharacterSpaceGrid = True
- End With
- With .ParagraphFormat '段落格式
- .CharacterUnitFirstLineIndent = 0 '取消首行缩进
- .FirstLineIndent = CentimetersToPoints(0) '取消首行缩进
- .LineSpacingRule = wdLineSpaceSingle '单倍行距(.Space1)
- .Alignment = wdAlignParagraphCenter
- .AutoAdjustRightIndent = False
- .DisableLineHeightGrid = True
- End With
- .Cells.VerticalAlignment = wdCellAlignVerticalCenter '垂直居中
- End With
- End With
-
- t.Select
- For Each c In Selection.Cells
- Do
- c.Select
- Selection.Find.Execute FindText:=Chr(13) & Chr(7), replacewith:="", Replace:=wdReplaceAll
- Loop Until Selection.Find.Found = False
- Next
- Next
- '删除空行
- Dim i As Paragraph
- For Each i In ActiveDocument.Paragraphs
- i.Range.Select
- If Len(i.Range) = 1 Then i.Range.Delete
- Do
- If Selection.Characters(1).Text = Chr(10) Then Selection.Characters(1).Delete
- Loop Until Selection.Characters(1).Text <> Chr(10)
- Next
- '删除表格空白行
- 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
-
- '光标移至文首
- Selection.HomeKey unit:=wdStory
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|