Adding a border in Excel using VB.NET
-
I am trying to add a border to the bottom of a range in Excel. It is easy to add a border on all four sides using the BordersAround Method, but I can't figure out how to add a border to the bottom of the cell only. Can any one tell me how to do this? Thanks! nvmoss
-
I am trying to add a border to the bottom of a range in Excel. It is easy to add a border on all four sides using the BordersAround Method, but I can't figure out how to add a border to the bottom of the cell only. Can any one tell me how to do this? Thanks! nvmoss
Of course, you already know about adding the Excel library as a reference to your project. After that, adding a border should be easy:
Dim xl As New Excel.Application
xl.Workbooks.Open("c:\000\book1.xls")
With xl.Range("Data").Borders(Excel.XlBordersIndex.xlEdgeBottom)
.LineStyle = Excel.XlLineStyle.xlContinuous
.Weight = Excel.XlBorderWeight.xlThin
.ColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic
End With
xl.ActiveWorkbook.Save()
xl.Workbooks.Close()What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
-
I am trying to add a border to the bottom of a range in Excel. It is easy to add a border on all four sides using the BordersAround Method, but I can't figure out how to add a border to the bottom of the cell only. Can any one tell me how to do this? Thanks! nvmoss
-
Here's the secret to coding Excel with VBA. Use the Macro Recorder.
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler. Support Bone It's a weird Life