PC Review


Reply
Thread Tools Rate Thread

Change Color for Drawing Line Object

 
 
smandula
Guest
Posts: n/a
 
      31st May 2010
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
-----------------------------------------------------------

With Thanks
I tried the recorded macro to format the Line to Red.
The macro comes back empty.

 
Reply With Quote
 
 
 
 
Ed Ferrero
Guest
Posts: n/a
 
      31st May 2010
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
 
Reply With Quote
 
Jim Cone
Guest
Posts: n/a
 
      31st May 2010

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" <(E-Mail Removed)>
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
-----------------------------------------------------------

With Thanks
I tried the recorded macro to format the Line to Red.
The macro comes back empty.

 
Reply With Quote
 
smandula
Guest
Posts: n/a
 
      31st May 2010
Thanks everyone for your help


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drawing toolbar: line color button hammonl Microsoft Excel Misc 1 25th Aug 2009 03:25 PM
Can't change macro assigned to drawing object =?Utf-8?B?TWFycXVpc0I=?= Microsoft Excel Programming 5 3rd Feb 2007 03:23 PM
Line Position Drawing Object =?Utf-8?B?TWFydmlu?= Microsoft Excel Programming 10 29th Oct 2006 12:12 AM
weight limit in the line drawing object? =?Utf-8?B?bWFubmk=?= Microsoft Frontpage 1 15th Jun 2006 09:35 PM
How do I draw a line without using a drawing object =?Utf-8?B?Um9iaW4=?= Microsoft Frontpage 2 2nd Dec 2004 09:12 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:39 PM.