|
楼主 |
发表于 2017-5-1 21:45
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
这个就弥补了我当年的第二个问题,选中的操作:
- Sub 自动干掉空格()
- Dim rg As Range, re As Object
- Set re = CreateObject("vbscript.regexp")
- With re
- .Global = 1
- .MultiLine = 1
- .ignorecase = 1
- .Pattern = "^[\s\u3000]+|[\u3000\s]+(?=[\r\n])$"
- End With
- Set rg = IIf(Selection.Type = wdSelectionIP, ActiveDocument.Range, Selection.Range)
- Set ma = re.Execute(rg)
- For i = ma.Count - 1 To 0 Step -1
- st = ma(i).firstindex: en = ma(i).firstindex + ma(i).Length
- ActiveDocument.Range(st, en) = ""
- 'if instr(ActiveDocument.Range(st, en).Style,"正文") Then 自定义动作
- ' If ActiveDocument.Range(st, en).ParagraphFormat.OutlineLevel = wdOutlineLevelBodyText Then 自定义动作
- Next
- End Sub
复制代码 |
|