I am having trying to set border of word table from Excel VBA. Many sites suggest the following:
wrdTable.Borders(wdBorderTop).LineStyle = wdLineStyleSingle
but I get an error (The requested member of the collection does not exist) while trying it. However, I could bring inner borders using following code:
wrdTable.Borders(xlDiagonalUp).LineStyle = xlContinuous
Similarly I tried:
wrdTable.Borders(xlEdgeTop).LineStyle = xlContinuous
to bring top borders, but I get diagonal lines. How could I apply borders (inner and outside borders) in my word tables? I am using office 2007.
These articles will put you on the right track:
http://www.shaunakelly.com/word/formatting/border-basics.html
http://www.shaunakelly.com/word/styles/borders-in-table-styles.html
Assuming your
wrdTableis properly set to the table object in msword’s document you have a few options:Setting this to True set’s the object’s borders to the same line style and line width as the current default border properties for this object.
Otherwise guidelines are
Heres a more detailed version:
For additional reference on syntax, see this page:
http://msdn.microsoft.com/en-us/library/office/aa221392(v=office.11).aspx
(note, I’ve typed this code from my mobile phone, so it is untested)