Could anyone give me the line of code you would use to draw a border
around a cell range in ruby? I know how to change the interior color of
a cell like so:
I found documentation for the Borders property, BorderAround object and
a few other things but the docs are for VB and am not sure the proper
syntax for ruby.
I have gotten most of my info so far from here http://wiki.rubygarden.org/Ruby/page/show/ScriptingExcel but still
cannot figure this one out.
The OLE error says unable to set the Weight property of the Borders
class. Same for Line Style. This makes me think that maybe the values I
am trying to set it to are incorrect since this also happens when I try
to change the color index to something like 99. So I believe I am
accessing the property correctly but not setting the correct value,
however all the examples I could find use those values.
Any ideas?
Have you tried recording a macro in Excel and taking a look at the VB
code it generates? It should point you in the right direction. Did you
try xlThin?
Here’s a sample macro generated with Excel
Range(“E1:H2”).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With