不好意思,杜先生!你的代码无效,我的有效:
Sub删除段落首尾空格()
''全选/居中/两端对齐,通过这三步键盘按键操作可以删除首尾空格。
''[方法1]
''SendKeys"^(aej)",True''表示按下ctrl键,同时按下A,E,J
''[方法2]
''Selection.WholeStory
''Application.Run"CenterPara"
''Application.Run"LeftPara"
''[方法3]
''Selection.WholeStory
''CommandBars.FindControl(ID:=122).Execute
''CommandBars.FindControl(ID:=123).Execute
''[方法4]
''删除段落首尾空格(表格后须加空)
WithActiveDocument.Content.Find
.Execute"(^13)([^s^t]{1,})",,,1,,,,,,"\1",2
.Execute"([^s^t]{1,})(^13)",,,1,,,,,,"\2",2
EndWith
EndSub
--------------------
我也不好意思,虽然你的代码简洁,也还是不如我的:
1.首段段落前的空格不能删除;
2.把末段的段落设置变成两端对齐,这一点很重要,末段通常是落款日期,居右,空4字;
3.在末尾还凭空增加了一行空行。
我的代码的缺陷我也知道,对成千上万段的文档,处理起来速度上有问题
|
|