View Single Post
  #2  
Old 15-08-2008, 23:34
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,787
Blog Entries: 11
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Randomize me...

Here is a little code that does just that, basically it checks to make sure your shape has an outline, then makes sure it is black, then randomly picks a color from the ActivePalette to fill the black outline. Enjoy!
Code:
Sub RandomizeOutlineColor()
    Dim n As Long, num As Long
    Dim s As Shape
    
    num = ActivePalette.ColorCount 'Get the number of colors in our palette
    
    Optimization = True
    
        For Each s In ActivePage.Shapes
            If s.Outline.Type = cdrOutline Then
                n = CLng(Fix(Rnd() * num)) + 1 'Get a random color from the palette
                If s.Outline.Color.Name = "Black" Then s.Outline.Color = ActivePalette.Color(n)
            End If
        Next s
        
    Optimization = False
    ActiveWindow.Refresh
End Sub
If you have CorelDRAW X4 you can easily find the black outline shapes with a little CQL. Code would look like this:
Code:
Sub RandomizeOutlineColorX4()
    Dim n As Long, num As Long
    Dim s As Shape
    
    num = ActivePalette.ColorCount 'Get the number of colors in our palette
    
    Optimization = True
    
        For Each s In ActivePage.Shapes.FindShapes(Query:="@outline.color = 'black'")
            n = CLng(Fix(Rnd() * num)) + 1 'Get a random color from the palette
            s.Outline.Color = ActivePalette.Color(n)
        Next s
        
    Optimization = False
    ActiveWindow.Refresh
End Sub
Best of luck!

-Shelby
Reply With Quote