The macro process all story ranges which can prove awkward when selecting the tables in order to determine whether to process them, so for the following I have added a prompt for each table in the body of the document that does not match the chosen criteria. Those tables not in the body of the document are simply processed without a prompt.
Change the part of the code that processes the tables as follows
Code:
Private Sub FormatTable(oTable As Table)
Const lngBackColor As Long = wdColorGray10
If oTable.Range.InRange(ActiveDocument.Range) = True Then
With oTable
If Not .Borders.OutsideLineStyle = wdLineStyleNone And _
Not .Borders.InsideLineStyle = wdLineStyleNone And _
Not .Shading.BackgroundPatternColor = lngBackColor Then
.Select
If MsgBox("Format the selected table?", vbYesNo, "Format tables") = vbYes Then
.Borders.OutsideLineStyle = wdLineStyleNone
.Borders.InsideLineStyle = wdLineStyleNone
.Shading.BackgroundPatternColor = lngBackColor
End If
End If
End With
Else
With oTable
.Borders.OutsideLineStyle = wdLineStyleNone
.Borders.InsideLineStyle = wdLineStyleNone
.Shading.BackgroundPatternColor = lngBackColor
End With
End If
lbl_Exit:
Exit Sub
End Sub