title: How to add borders around Excel range using C#?
body: <p>Could somebody tell me how to add borders around the outside of a range of cells in another colour? Ideally I would like to be able to do this with a single method I will have to do this multiple times. After searching for this I found two methods that would apparently do this - <code>BorderAround</code> and <code>BorderAround2</code>. I suppose my first question is what is the difference between these two methods? I tried using each of these and only <code>BorderAround2</code> was recognised?</p>
  
  <p>Anyway, `BorderAround2' almost does what I wanted. I used the following line of code which did put a border around the outside of the range, but it was black, rather than red:</p>
  
  <pre><code>ws.get_Range("B2", "E3").BorderAround2(Excel.XlLineStyle.xlContinuous, Excel.XlBorderWeight.xlThick, Excel.XlColorIndex.xlColorIndexNone, Color.FromArgb(255, 0, 0), Type.Missing);
  </code></pre>
  
  <p>The <a href="http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.namedrange.borderaround2.aspx" rel="nofollow noreferrer">MSDN documentation</a> for this method states: </p>
  
  <blockquote>
    <p>You must specify either ColorIndex or Color, but not both.</p>
  </blockquote>
  
  <p>How do I go about doing this? If I set the <code>ColourIndex</code> parameter to <code>Type.Missing</code> or to <code>null</code> or miss it out completely, it produces an error. Any help would be appreciated.</p>
  
  <p>Finally I should point out that I found a workaround solution <a href="https://stackoverflow.com/questions/11743809/how-to-set-a-border-around-multiple-cells-in-excel-with-c-sharp">here</a> where you set the set the various edges separately, but as I say, I was hoping to do this using a single method as it has to be repeated multiple times.</p>