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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top