检测journal格式
Sub 检测格式sss()
Dim MainR As Range
Dim mainrange As Range
Dim MainCount As Integer
Dim j As Integer
Call layout_search_replace.jump_to_reference_section
Set mainrange = ActiveDocument.Range(Start:=ActiveDocument.Range.Start, End:=selection.Range.End)
MainCount = mainrange.Paragraphs.count
Set MainR = ActiveDocument.Range(Start:=ActiveDocument.Range.Start, End:=ActiveDocument.Paragraphs(MainCount).Range.End)
Dim mainpara As Integer
mainpara = MainR.Paragraphs.count
Call layout_search_replace.jump_to_reference_section
selection.MoveDown wdLine, 1
MsgBox mainpara
For j = mainpara To ActiveDocument.Paragraphs.count -1
Dim ss As String
ss = selection.Paragraphs(1).Range.Text
Dim arr, name
Dim names, i As Integer
arr = Split(ss, ". ")
names = arr(0) + "."
Dim namelen As Integer
namelen = Len(names)
name = Split(names, ";")
For i = LBound(name) To UBound(name)
Dim reg
Set reg = CreateObject("vbscript.regexp")
reg.Pattern = "[A-Z][\w|-]+\, ([A-Z]\.)+\;"
If reg.test(arr(1)) Then
ActiveDocument.Range(selection.Paragraphs(1).Range.Start, selection.Paragraphs(1).Range.Start + namelen).HighlightColorIndex = wdYellow
End If
If reg.test(name(i) + ";") Then
If testName(name(i) + ";") = False Then
Else
ActiveDocument.Range(selection.Paragraphs(1).Range.Start, selection.Paragraphs(1).Range.Start + namelen).HighlightColorIndex = wdYellow
End If
End If
If reg.test(name(i) + ";") = False Then
ActiveDocument.Range(selection.Paragraphs(1).Range.Start, selection.Paragraphs(1).Range.Start + namelen).HighlightColorIndex = wdYellow
End If
Next i
selection.MoveDown wdParagraph, 1
Next j
End Sub
Function testName(str As String) As Boolean
Dim is_exist As Boolean
is_exist = False
Set reg = CreateObject("VBScript.Regexp")
reg.Global = True: reg.Pattern = "\,"
If reg.Execute(str).count > 1 Then
is_exist = True
End If
testName = is_exist
End Function