View Single Post
 
Old 11-25-2011, 10:44 PM
tinfanide tinfanide is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default Word VBA: add borders to active table

Code:
Sub table()

    With ActiveDocument
    
    .Tables.Add Range:=Selection.Range, _
    NumRows:=3, _
    NumColumns:=3, _
    DefaultTableBehavior:=wdWord8TableBehavior
    
' I want to select this table
' and add borders
    
    End With

    With ActiveDocument.Tables(2)
    
        .Borders(wdBorderTop).LineStyle = wdLineStyleSingle
        .Borders(wdBorderLeft).LineStyle = wdLineStyleSingle
        .Borders(wdBorderBottom).LineStyle = wdLineStyleSingle
        .Borders(wdBorderRight).LineStyle = wdLineStyleSingle
        .Borders(wdBorderHorizontal).LineStyle = wdLineStyleSingle
        .Borders(wdBorderVertical).LineStyle = wdLineStyleSingle
        .Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleSingle
        .Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleSingle
    
    End With


End Sub
Please see the comments above.
Please help, thx!
Reply With Quote