|
- Sub 提取感叹句()
- Dim i As String, v As Long, doc As Document
- i = ActiveDocument.Name
- Set doc = Documents.Add
- Documents(i).Activate
- Selection.EndKey Unit:=wdStory
- Selection.Find.ClearFormatting
- Do While Selection.Find.Execute(findtext:="!", Forward:=False)
- Do
- v = Len(Selection)
- Selection.MoveStart Unit:=wdCharacter, Count:=-1
- If Len(Selection) = v Then GoTo imhere
- Loop Until Selection Like "[.!?]*" '中括号内是分隔感叹句的标点符号,可自行增减
- Selection.MoveStart Unit:=wdCharacter, Count:=1
- If Selection.Characters(1) = " " Then Selection.MoveStart Unit:=wdCharacter, Count:=1
- imhere:
- ' Selection.Font.Color = wdColorRed '红色
- Selection.Copy
- doc.Content.Paste
- Selection.MoveLeft Unit:=wdCharacter, Count:=1
- Loop
- doc.Paragraphs(1).Range.Delete
- Documents(i).Close savechanges:=wdDoNotSaveChanges
- MsgBox "提取完毕!文档尚未保存,请自行保存!", vbOKOnly + vbExclamation, "提取感叹句"
- End Sub
复制代码 |
|