Change Color for Drawing Line Object

S

smandula

Below is code for a line drawing, but it defaults to Blue.
I would like to change the color to red.
------------------------------------------------
Sub mineLeft()

Dim nStart1 As Double, nStart2 As Double
Dim nEnd1 As Double, nEnd2 As Double
Dim rng1 As Range
Dim rng2 As Range

Set rng1 = ActiveCell.Offset(0, -1)
Set rng2 = ActiveCell.Offset(1, 0)
nStart1 = rng1.Left + rng1.Width
nStart2 = rng1.Top
nEnd1 = rng2.Left + rng2.Width
nEnd2 = rng2.Top

ActiveSheet.Shapes.AddLine(nStart1, nStart2, nEnd1, nEnd2).Select

End Sub
 
E

Ed Ferrero

Hi smandula,
ActiveSheet.Shapes.AddLine(nStart1, nStart2, nEnd1, nEnd2).Select

Change this line to
Set shp = ActiveSheet.Shapes.AddLine(nStart1, nStart2, nEnd1, nEnd2)
shp.Line.ForeColor.RGB = RGB(255, 0, 0)

Ed Ferrero
www.edferrero.com
 
J

Jim Cone

Re: "The macro comes back empty."
Excel 2007 was released when it was "good enough"...

ActiveSheet.Shapes.AddLine(nStart1, nStart2, nEnd1, nEnd2).Line.ForeColor.SchemeColor = 10
--
Jim Cone
Portland, Oregon USA
(Shade Data Rows Excel add-in: http://tinyurl.com/ShadeData )








"smandula" <[email protected]>
wrote in messageBelow is code for a line drawing, but it defaults to Blue.
I would like to change the color to red.
------------------------------------------------
Sub mineLeft()

Dim nStart1 As Double, nStart2 As Double
Dim nEnd1 As Double, nEnd2 As Double
Dim rng1 As Range
Dim rng2 As Range

Set rng1 = ActiveCell.Offset(0, -1)
Set rng2 = ActiveCell.Offset(1, 0)
nStart1 = rng1.Left + rng1.Width
nStart2 = rng1.Top
nEnd1 = rng2.Left + rng2.Width
nEnd2 = rng2.Top

ActiveSheet.Shapes.AddLine(nStart1, nStart2, nEnd1, nEnd2).Select

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top