Question: How can I add a colored border to a cell in C# Excel VSTO?

I found the API via the following link, and there're some descriptions regarding adding borders, but not very specific. The weird thing is VS2010 doesn't recognize `BorderAround()` method. It seems to only recognize `BorderAround2()`, but complaining the arguments I put int.

Below is the code that I tried, but VS complains about the invalid arguments. 

```
range.BorderAround2(Excel.XlLineStyle.xlDash, Type.Missing, Type.Missing, System.Drawing.Color.Red, Type.Missing);

```

<http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.range.borderaround(v=office.14).aspx>

Answer: 
My own approach is similar to what idssl suggested, but utilizing [ColorTranslator.ToOle](http://msdn.microsoft.com/en-us/library/system.drawing.colortranslator.toole.aspx) method.

```
range.Borders.LineStyle = Excel.XlLineStyle.xlDot;
range.Borders.Color = ColorTranslator.ToOle(Color.Red);

```

Which also works for me.
Use the `Borders.Color` and `Bordes.LineStyle` properties of the `Range` object.

This is a snippet from a VSTO application-level addin.

```
using Excel = Microsoft.Office.Interop.Excel;

Excel.Range pRange = Globals.ThisAddIn.Application.ActiveCell;

pRange.Borders.Color = 0x0000FF; // an RGB value in hex
pRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;

```

Note that the `Borders.Color` property uses the inverse of the supplied RGB value as the color.

Alternatively, you could use the `ColorIndex` property, but the range of colors is limited. See [this](http://msdn.microsoft.com/en-us/library/office/cc296089%28v=office.12%29.aspx) for more details.