revise 11-29
Sub citationOrder()
Dim currNum, lastCall As Integer
lastCall = 0
Selection.HomeKey wdStory
arr = "<Table [0-9]{1,}>;<Figure [0-9]{1,}>;<Scheme [0-9]{1,}>"
aimT = Split(arr, ";")
For i = 0 To UBound(aimT)
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Font.Bold = False
.Text = aimT(i)
.Format = True
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
Do
.Execute
If Not .Found Then
Exit Do
ElseIf .Found Then
currNum = FunctionGroup.getNum(Selection.Text)
If currNum - lastCall > 0 Then
If currNum - lastCall <> 1 Then
lastCall = currNum
If j = 0 Then
Selection.Range.HighlightColorIndex = wdRed
Selection.Range.comments.Add Selection.Range, "Detect that no " + Left(Selection.Text, InStr(Selection.Text, " ")) + "citation is before " + Selection.Text + " Please check if the " + Left(Selection.Text, InStr(Selection.Text, " ")) + "order is correct."
lastCall = 1
Else
Selection.Range.HighlightColorIndex = wdRed
Selection.Range.comments.Add Selection.Range, "Detect " + Selection.Text + " is after of " + Left(Selection.Text, InStr(Selection.Text, " ")) + CStr(preNum) + " Please check if the " + Left(Selection.Text, InStr(Selection.Text, " ")) + "order is correct."
End If
End If
preNum = currNum
End If
End If
j = j + 1
Loop
End With
Next
End Sub