View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
bhofsetz[_71_] bhofsetz[_71_] is offline
external usenet poster
 
Posts: 1
Default Changing the Colour of an Auto Shape (Line)


You can actually avoid that IF statement altogether and take bette
advantage of your Select Case statement.

see modified code below:


Code
-------------------
Sub TestShoot()
Call DrawShooting(171#, 115.5, 255.75, 167.25, 20, "BLUE")
End Sub

Sub DrawShooting(StartX As Single, StartY As Single, EndX As Single, EndY As Single, _
Shots As Integer, Optional Color As String)
Dim Shot As Shape
Dim i As Integer
Dim j As Integer

Select Case Color
Case "GREEN"
For i = 1 To Shots
Set Shot = ActiveSheet.Shapes.AddLine(StartX, StartY, EndX, EndY)
For j = 1 To 255
Shot.Line.ForeColor.RGB = RGB(0 + j, 255, 0 + j)
Application.Wait Now() + 0.0000007
Next
Shot.Delete
Next
Case "BLUE"
For i = 1 To Shots
Set Shot = ActiveSheet.Shapes.AddLine(StartX, StartY, EndX, EndY)
For j = 1 To 255
Shot.Line.ForeColor.RGB = RGB(0 + j, 0 + j, 255)
Application.Wait Now() + 0.0000007
Next
Shot.Delete
Next
Case Else
For i = 1 To Shots
Set Shot = ActiveSheet.Shapes.AddLine(StartX, StartY, EndX, EndY)
For j = 1 To 255
Shot.Line.ForeColor.RGB = RGB(255, 0 + j, 0 + j)
Application.Wait Now() + 0.0000007
Next
Shot.Delete
Next

End Select
End Su
-------------------


HT

--
bhofset
-----------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...fo&userid=1880
View this thread: http://www.excelforum.com/showthread.php?threadid=38126