View Single Post
 
Old 10-25-2021, 01:32 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
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

You need to exit the sub before the error message, or forget the error message and make sure it doesn't appear e.g.
Code:
Sub FormatTable()
    If Selection.Information(wdWithInTable) = True Then
        Selection.Tables(1).Select
        With Selection.Tables(1)
            With .Borders(wdBorderLeft)
                .LineStyle = wdLineStyleThinThickSmallGap
                .LineWidth = wdLineWidth300pt
                .Color = wdColorAutomatic
            End With
            With .Borders(wdBorderRight)
                .LineStyle = wdLineStyleThinThickSmallGap
                .LineWidth = wdLineWidth300pt
                .Color = wdColorAutomatic
            End With
            With .Borders(wdBorderTop)
                .LineStyle = wdLineStyleThinThickSmallGap
                .LineWidth = wdLineWidth300pt
                .Color = wdColorAutomatic
            End With
            With .Borders(wdBorderBottom)
                .LineStyle = wdLineStyleThinThickSmallGap
                .LineWidth = wdLineWidth300pt
                .Color = wdColorAutomatic
            End With
            With .Borders(wdBorderHorizontal)
                .LineStyle = wdLineStyleSingle
                .LineWidth = wdLineWidth050pt
                .Color = wdColorAutomatic
            End With
            With .Borders(wdBorderVertical)
                .LineStyle = wdLineStyleSingle
                .LineWidth = wdLineWidth050pt
                .Color = wdColorAutomatic
            End With
            .Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
            .Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
            .Borders.Shadow = False
        End With
        With Options
            .DefaultBorderLineStyle = wdLineStyleSingle
            .DefaultBorderLineWidth = wdLineWidth050pt
            .DefaultBorderColor = wdColorAutomatic
        End With
        Selection.Font.Bold = True
        Selection.Font.BoldBi = True
        Selection.Font.Size = 14
        Selection.Font.Name = "Times New Roman"
    Else
        MsgBox "Select a Table First", vbCritical
    End If
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