|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
试试如下代码【别告诉我你不会用】:
完成后可将文档转换为表格。然后你自己排序,手动将第二列删除,再表格-转换-表格转换为文本即可。
Sub sdf()
On Error Resume Next
Application.ScreenUpdating = 0
ActiveDocument.Range.InsertAfter vbNewLine & "★"
With Selection.Find
.Parent.HomeKey wdStory
.Text = "★[!★]@★"
.MatchWildcards = 1
Do While .Execute
If Len(.Parent) < 20 Then Exit Do
.Parent.End = .Parent.End - 1
Selection.Cut
Selection.Tables.Add Selection.Range, 1, 1
Selection.Paste
Selection.TypeBackspace
Selection.Tables(1).Style = "网格型"
Loop
End With
ActiveDocument.Tables(1).Columns.Add
With Selection.Find
.Parent.HomeKey wdStory
.Text = "审判法庭:*^13"
.MatchWildcards = 1
Do While .Execute
.Parent.Start = .Parent.Start + 5
Selection.Copy
Selection.Cells(1).Select
Selection.MoveRight
Selection.Paste
Selection.TypeBackspace
Loop
End With
'' Selection.Tables(1).Columns(2).Select
'' Selection.Sort ExcludeHeader:=False, FieldNumber:="列 2"
'' Selection.Tables(1).Columns(2).Delete
'' Selection.Tables(1).ConvertToText
Application.ScreenUpdating = 1
End Sub
|
|