私は同じ問題を抱えていましたが、ウェブ上で解決策を見つけることができませんでした。VSTOでこのメソッドを使用するためのMSドキュメントは少し貧弱です。
とにかく、数か月前に投稿したので、おそらく少し遅れますが、私の回避策は、Range.BorderAroundメソッドを使用せず、独自のメソッドを作成することでした。
private void BorderAround(Excel.Range range, int colour)
{
Excel.Borders borders = range.Borders;
borders[Excel.XlBordersIndex.xlEdgeLeft].LineStyle = Excel.XlLineStyle.xlContinuous;
borders[Excel.XlBordersIndex.xlEdgeTop].LineStyle = Excel.XlLineStyle.xlContinuous;
borders[Excel.XlBordersIndex.xlEdgeBottom].LineStyle = Excel.XlLineStyle.xlContinuous;
borders[Excel.XlBordersIndex.xlEdgeRight].LineStyle = Excel.XlLineStyle.xlContinuous;
borders.Color = colour;
borders[Excel.XlBordersIndex.xlInsideVertical].LineStyle = Excel.XlLineStyle.xlLineStyleNone;
borders[Excel.XlBordersIndex.xlInsideHorizontal].LineStyle = Excel.XlLineStyle.xlLineStyleNone;
borders[Excel.XlBordersIndex.xlDiagonalUp].LineStyle = Excel.XlLineStyle.xlLineStyleNone;
borders[Excel.XlBordersIndex.xlDiagonalDown].LineStyle = Excel.XlLineStyle.xlLineStyleNone;
borders = null;
}
以下の例のように呼び出すことができます(Contents_Tableは私のワークシートのNamedRangeです):
BorderAround(Contents_Table.Cells, System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.FromArgb(79, 129, 189)));
これが他の誰かが自分の髪を引き裂くのに役立つことを願っています。