Quote:
Originally Posted by gmayor
You need to exit the sub before the error message.
|
Thank you very much
Just to learn and according to your instructions, the code will be
Code:
Sub FormatTable()
'
On Error GoTo ErrMsg
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 = wdToggle
Selection.Font.BoldBi = wdToggle
Selection.Font.Size = 14
Selection.Font.Name = "Times New Roman"
Exit Sub
ErrMsg: MsgBox "Select a Table Firstly", vbCritical
End Sub