kerrypnx
10/30/2018 - 6:19 AM

back matter order

revise 10-30

Sub backOrder()
Dim str, frontT As String
Dim myrange As Range
str = "Supplementary Materials:,Author contributions:,Funding:,Acknowledgments:,Conflicts of Interest:,Abbreviations:,Appendix:,References:"
backM = Split(str, ",")
Set dict = CreateObject("Scripting.Dictionary")
Dim j, lastCall
j = 1: lastCall = 0
    For i = LBound(backM) To UBound(backM)
    
        dict.Add UCase(backM(i)), CStr(i)
    Next
Selection.HomeKey wdStory
With Selection.Find
    .ClearFormatting
    .Text = "[A-Z][a-z ]@\:"
    .Font.Size = 9
    .Font.Bold = True
    .MatchWildcards = True
    .Wrap = wdFindStop
    .Forward = True
    Do
    .Execute
    If Not .Found Then
        Exit Do
    Else
        Set myrange = ActiveDocument.Range(Selection.Paragraphs(1).Range.Start, Selection.Range.End)
        myrange.Select
       If dict.Exists(UCase(myrange.Text)) = True Then
            If dict(UCase(myrange.Text)) > lastCall Then
                lastCall = dict(UCase(myrange.Text))
            Else
                myrange.comments.Add myrange, "'" + myrange.Text + "' " + "must be in front of " + "'" + frontT + "'"
            End If
        End If
    End If
        frontT = myrange.Text
        Selection.Collapse wdCollapseEnd
    Loop
End With
End Sub