|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
请楼主关闭所有Word文档后,将原文件备份后放到一个新建文件夹中(Word2003测试通过):
- Sub test()
- Dim doc As Document, i$
- Set doc = ActiveDocument
- Do
- If Len(doc.Content) = 1 Then doc.Close savechanges:=wdDoNotSaveChanges: End
- Do
- doc.Paragraphs(1).Range.Select
- CommandBars.FindControl(ID:=122).Execute
- CommandBars.FindControl(ID:=123).Execute
- If Len(Selection) = 1 Then Selection.Delete Else i = Selection.Text: Exit Do
- Loop
- i = Replace(i, vbCr, "")
- Selection.HomeKey unit:=wdStory
- Selection.Find.Execute Chr(12), , , 1, , , 1
- If Selection.Find.Found = True Then
- Selection.HomeKey unit:=wdStory, Extend:=wdExtend
- cont:
- Selection.Cut
- Selection.Delete
- Documents.Add.SaveAs FileName:=i, fileformat:=wdFormatDocument
- Selection.Paste
- ActiveDocument.Characters(1).Copy
- ActiveDocument.Paragraphs.Last.Range.Delete
- ActiveDocument.Close savechanges:=wdSaveChanges
- Else
- Selection.WholeStory
- GoTo cont
- End If
- Loop
- End Sub
复制代码 |
|