楼主,如果文档较大,请耐心等待,不要动键盘、鼠标,请试用下面的宏:
- Sub test删除重复字符()
- Dim i&, j&, k&, m&, n$, t As Table
- For Each t In ActiveDocument.Tables
- t.Rows.ConvertToText Separator:=wdSeparateByParagraphs, NestedTables:=True
- Next
- With ActiveDocument.Content.Find
- .Execute "^13", , , 0, , , , , , "", 2
- .Execute "^11", , , 0, , , , , , "", 2
- .Execute "^w", , , 0, , , , , , "", 2
- End With
- With Selection
- .WholeStory
- .ClearFormatting
- .HomeKey Unit:=wdStory
- With .Find
- .ClearFormatting
- Do
- m = m + 1
- With .Parent
- .MoveRight 1, 1, 1
- If .Text = vbCr Then Exit Do
- .Font.Underline = wdUnderlineSingle
- n = .Text
- .MoveRight 1, 1
- End With
- .Execute n, , , 0, , , , , , "", 2
- Loop
- End With
- .WholeStory
- .ClearFormatting
- .HomeKey Unit:=wdStory
- Do
- .MoveRight 1, 1
- .TypeParagraph
- Loop Until .Text = vbCr
- .Delete 1, 1
- .WholeStory
- .Sort ExcludeHeader:=False, FieldNumber:="段落数", SortFieldType:= _
- wdSortFieldSyllable, SortOrder:=wdSortOrderAscending, FieldNumber2:="", _
- SortFieldType2:=wdSortFieldSyllable, SortOrder2:=wdSortOrderAscending, _
- FieldNumber3:="", SortFieldType3:=wdSortFieldSyllable, SortOrder3:= _
- wdSortOrderAscending, Separator:=wdSortSeparateByTabs, SortColumn:=False, _
- CaseSensitive:=False, LanguageID:=wdSimplifiedChinese, SubFieldNumber:= _
- "段落数", SubFieldNumber2:="段落数", SubFieldNumber3:="段落数"
- .HomeKey Unit:=wdStory
- End With
- MsgBox "处理完毕!!!!!!!!!!!!", 0 + 48
- End Sub
复制代码 |