|
139:试试这次的代码,一般地说是行了,但不保证绝对正确:
- Sub 查找不成对符号()
- Dim a, b, i As Long
- a = Array("‘", "“", "(", "[", "{", "〔", "〈", "《", "「", "『", "〖", "【")
- b = Array("’", "”", ")", "]", "}", "〕", "〉", "》", "」", "』", "〗", "】")
- ActiveDocument.Content.InsertBefore Text:=vbCr
- Do
- '前符号
- Selection.HomeKey Unit:=wdStory
- Selection.Find.ClearFormatting
- Do While Selection.Find.Execute(findtext:=a(i), Forward:=True)
- Do
- Selection.MoveEnd Unit:=wdCharacter, Count:=1
- If Selection.Characters.Last.Text = vbCr Then GoTo aaa
- If Selection.Characters.Last.Text = b(i) Then
- Exit Do
- ElseIf Selection.Characters.Last.Text = a(i) Then
- aaa:
- Selection.Characters.First.Font.Color = wdColorRed '红色
- Selection.Characters.First.Font.Underline = wdUnderlineWavyHeavy '重波浪线
- Selection.MoveEnd Unit:=wdCharacter, Count:=-1
- Exit Do
- End If
- Loop
- Selection.MoveRight Unit:=wdCharacter, Count:=1
- Loop
- '后符号
- Selection.EndKey Unit:=wdStory
- Selection.Find.ClearFormatting
- Do While Selection.Find.Execute(findtext:=b(i), Forward:=False)
- Do
- Selection.MoveStart Unit:=wdCharacter, Count:=-1
- If Selection.Characters.First.Text = vbCr Then GoTo bbb
- If Selection.Characters.First.Text = b(i) Then
- bbb:
- If Len(Selection) <= 7 And Selection Like vbCr & "*[0-9a-zA-Z0-9a-zA-Z一二三四五六七八九十百零甲乙丙丁戊己庚辛壬癸])" Then GoTo ccc
- Selection.Characters.Last.Font.Color = wdColorRed '红色
- Selection.Characters.Last.Font.Underline = wdUnderlineWavyHeavy '重波浪线
- Selection.MoveStart Unit:=wdCharacter, Count:=1
- Exit Do
- ElseIf Selection.Characters.First.Text = a(i) Then
- Exit Do
- End If
- Loop
- ccc:
- Selection.MoveLeft Unit:=wdCharacter, Count:=1
- Loop
- i = i + 1
- Loop Until i = 12
- If ActiveDocument.Paragraphs(1).Range.Text = vbCr Then ActiveDocument.Paragraphs(1).Range.Delete
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|