Problems setting border.linestyle in Office 2007

E

EBenson

This code works for pre-Excel 2007 and not Excel 2007 ( Com-Addin using c#):

(1) style.Borders[Excel.XlBordersIndex.xlEdgeRight].LineStyle =
Excel.XlLineStyle.xlContinuous;

if I change it to the following (casting the constant instead of using the
XlBordersIndex value)it will work in 2007:

(2) style.Borders[(Excel.XlBordersIndex)Excel.Constants.xlRight].LineStyle =
Excel.XlLineStyle.xlContinuous;

Anyone know why (1) will work in previous Excel versionsand not in 2007?

Why changing to (2) works in 2007?

BTW, (1) can be used to correctly change xlEdgeLeft on any Excel version. It
is only xlEdgeRight, xlEdgeBottom, and xlEdgeTop that will not work in Excel
2007.

TIA
 
E

EBenson

the answer is ... the Style Borders and Range Borders use different enums.
Style uses the Constants.xlLeft and Range uses xlEdgeLeft. Why the Range
values worked in my pre- Excel 2007 code is beyond me.
 
Top