Sub detectPageRange()
Call layout_search_replace.jump_to_reference_section
Dim firstPage, lastPage As String
Dim arr
With Selection.Find
.ClearFormatting
.MatchWildcards = True
.Wrap = wdFindStop
.Text = " [0-9]@" + ChrW(8211) + "[0-9]{1,}"
.Replacement.Text = ""
Do
.Execute
If .Found Then
arr = Split(Selection.Text, ChrW(8211))
firstPage = Trim(arr(0))
lastPage = Trim(arr(1))
If CInt(firstPage) - CInt(lastPage) = 0 Then
Selection.comments.Add Selection.Range, "First page and last page are the same"
Else
If CInt(firstPage) - CInt(lastPage) > 0 Then
Selection.comments.Add Selection.Range, "First page is larger than last page"
End If
End If
Selection.MoveRight wdCharacter, 1
Else
Exit Do
End If
Loop
End With
End Sub