cuteword 兄: 又对上面的宏做了改进,将人工换行符替换为回车符的代码也加了进去,这样为后续的排版代理方便,对于下面链接例子中的文档全文,已经可以处理:http://space.univs.cn?5602/action_viewspace_itemid_25993.html 新的代码为: Sub Macro2() Selection.HomeKey Unit:=wdStory Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "^l" .Replacement.Text = "^p" .Forward = True .Wrap = wdFindContinue End With Selection.Find.Execute Replace:=wdReplaceAll ActiveWindow.View.ShowHiddenText = True Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "^?" .Font.Hidden = True .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = True End With Selection.Find.Execute Replace:=wdReplaceAll Selection.WholeStory Selection.Cut Selection.PasteAndFormat Type:=wdFormatPlainText ActiveWindow.View.ShowHiddenText = False End Sub 我试了一下可以的,不过另外一个宏(就是循环替换的)在运行的时候会停止在一处,程序跳不过去,word就死了,只能停掉宏,错误提示在“while wend”循环的代码,不知道是为什么,请查看: Sub delHtext() Selection.HomeKey Unit:=wdStory Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "^l" .Replacement.Text = "^p" .Forward = True .Wrap = wdFindContinue End With Selection.Find.Execute Replace:=wdReplaceAll ActiveWindow.View.ShowHiddenText = True Selection.Find.ClearFormatting With Selection.Find .Text = "^?" .Font.Hidden = True .Forward = True .Wrap = wdFindContinue .Format = True While .Execute Selection.Delete Unit:=wdCharacter, Count:=1 Wend End With Selection.WholeStory Selection.Cut Selection.PasteAndFormat Type:=wdFormatPlainText ActiveWindow.View.ShowHiddenText = False End Sub
[此贴子已经被作者于2007-6-14 12:54:26编辑过] |