在整理Word网页图文资料粘贴文档中,最主要、最烦的工作就是清除大量的软回车(换行符↓)和空段(空段硬回车符),在《用Word自动化快速整理网页资料(修改一)》中,已正确解决软回车的转换和多余软回车的清除,清除硬回车的任务尚未解决。在Wps的文字处理工具中也还存在不能完全正确处理软回车符的清除问题,而且Wps不能实现网页图文资料的直接拖放。经过反复学习-修改-验证,终于完成了一次性全自动清除软回车和硬回车空段的任务。现整理出来,献给需要、喜欢收集整理网页图文资料的朋友们,让朋友们能腾出更多的时间去做更多、更有益的事情。
打开Word(Word2003),选择“工具”→“宏”→“宏…”→单击“创建”按钮→自动打开“Visual Basic编辑器”,在Visual Basic编辑器窗口内复制/粘贴如下VBA代码:
Sub 整理网页()
'
'整理网页:全自动清除软回车和空段(233223222)
Selection.WholeStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "?^l"
.Replacement.Text = "^&^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^1^l"
.Replacement.Text = "^&^p"
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^l"
.Replacement.Text = ""
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^p^s"
.Replacement.Text = "^p"
.MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^p^p"
.Replacement.Text = "^p"
.MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^p^p^p"
.Replacement.Text = "^p"
.MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^p^p^p"
.Replacement.Text = "^p"
.MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^p^p"
.Replacement.Text = "^p"
.MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^p^p"
.Replacement.Text = "^p"
.MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^p^p^p"
.Replacement.Text = "^p"
.MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^p^p"
.Replacement.Text = "^p"
.MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^p^p"
.Replacement.Text = "^p"
.MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^p^p"
.Replacement.Text = "^p"
.MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
代码粘贴入编辑窗口后,选择“调试”→“编译Normal”,关闭编辑窗口。这时,选择Word文档窗口的“工具”→“宏”→“宏……”→出来“宏对话框”(如下图):里面就有了“整理网页”自动化工具了。当然,你还可以在工具栏上作个自定义按钮“整理网页”了……(用Word2000或Wordxp请网友们自行测试)
下面就可以用这个自动化工具来进行闪电似的整理Word粘贴文档了:
1,打开Word,将选取的网页图文资料直接用鼠标(左键)拖入Word文档中;
2,选择Word文档窗口的“工具”→“宏”→“宏……”→出来“宏对话框”,单击“整理网页”,选择“运行”按钮,瞬间就完成了全部软回车符“↓”及多余硬回车空段空行的处理;
3,接下来,只要对大小标题式样进行设置就可以了。如果要整理成标准Word文档,你就选择需要整理的图文部分,选“式样框”→“清除格式”,然后视情况按常规对大、小标题式样、段落缩进进行处理,对图片位置、缩进进行必要的调整,一个标准的Word文档很快就整理完成了。
4,你试试,是不是象闪电一般。欢迎给我反馈信息,谢谢了!(
联系客服