View Single Post
 
Old 12-28-2017, 09:40 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

A document comprises several story ranges. In this instance the macro processes all the story ranges, but only prompts for tables in the document that don't meet the required criteria that are in the main body of the document as opposed to (say) being in headers and footers.

Your original post said that the document had many tables, so to avoid prompting for tables that already met your criteria, the macro checks whether the tables meet the criteria before prompting. As the tables are single cell you can remove the lines that relate to the insidelinestyle.

If you want to select regardless.then remove the checks e.g.
Code:
Private Sub FormatTable(oTable As Table)
Const lngBackColor As Long = wdColorGray10
    If oTable.Range.InRange(ActiveDocument.Range) = True Then
        With oTable
            .Select
            If MsgBox("Format the selected table?", vbYesNo, "Format tables") = vbYes Then
                .Borders.OutsideLineStyle = wdLineStyleNone
                .Shading.BackgroundPatternColor = lngBackColor
            End If
        End With
    Else
        With oTable
            .Borders.OutsideLineStyle = wdLineStyleNone
            .Shading.BackgroundPatternColor = lngBackColor
        End With
    End If
lbl_Exit:
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote