|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 zhanglei1371 于 2014-11-7 14:00 编辑
仅仅针对题目有效,具体情况自己修改:
Sub sdf()
Selection.HomeKey wdStory
With Selection.Find
.Text = "[01234567890-9]@[, ,]@[01234567890-9]{1,}"
.MatchWildcards = 1
Do While .Execute
p = Replace(.Parent, ",", ", ")
a0 = Split(p, ", ")(0)
b0 = Split(p, ", ")(1)
a = StrConv(Split(p, ", ")(0), vbNarrow) '全角转半角
b = StrConv(Split(p, ", ")(1), vbNarrow)
If sta = "" Then sta = a0
If a + 1 = Val(b) Then
.Parent.Start = .Parent.End - Len(b)
i = i + 1
Selection.Collapse 1
Else
If i < 1 Then sta = "": .Parent.End = .Parent.End - 2: .Parent.Collapse 0: GoTo aa:
en = a0
Selection.HomeKey
Debug.Print sta & "[!^13]@" & en
Selection.Find.Execute sta & "[!^13]@" & en, , , 2, , , , , , sta & "-" & en, 1
Selection.Collapse 0
.Text = "[01234567890-9]@[, ,]@[01234567890-9]{1,}"
sta = ""
i = 0
End If
aa:
Loop
End With
End Sub |
评分
-
1
查看全部评分
-
|