Sub batchNCBI()
Selection.EndKey wdStory
Do
If Len(Selection.Paragraphs(1).Range.Text) < 3 Then
delay (300)
Selection.Paragraphs(1).Range.Delete
Else
Exit Do
End If
Loop
Dim aa, bb As Integer
Call layout_search_replace.jump_to_reference_section
Selection.Move wdParagraph, 1
Do While ActiveDocument.Range(Selection.Range.Start, Selection.Range.Start).End < ActiveDocument.Content.End - 1
Do
aa = Len(Selection.Text)
DoEvents
Selection.MoveEndUntil ","
bb = Len(Selection.Text)
Selection.MoveRight wdCharacter, 1, wdExtend
Loop While isBIBTex(Selection.Range.Text)
Selection.MoveLeft wdCharacter, bb - aa, wdExtend
If InputBox("Is this ncbi?", "NCBI", "yes", 300, 300) = "yes" Then
Call layout_feifei_liu.sFormatBibtexName
End If
Selection.MoveDown wdParagraph, 1
Loop
End Sub
Function isBIBTex(str As String) As Boolean
Dim reg As New RegExp
Dim is_exist, is_ncbi As Boolean
With reg
.Global = True
.Pattern = " [a-z]+ "
is_exist = reg.test(str)
End With
Dim match
Set match = reg.Execute(str)
If is_exist = True Then
If match(0) = " and " And match.count = 1 And FunctionGroup.existXing(str) Then
is_ncbi = True
Else
is_ncbi = False
End If
Else
If FunctionGroup.existXing(str) And FunctionGroup.existBookTitle(str) = False Then
is_ncbi = True
Else
is_ncbi = False
End If
End If
isBIBTex = is_ncbi
End Function