OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   CorelDRAW/Corel DESIGNER VBA (http://forum.oberonplace.com/forumdisplay.php?f=16)
-   -   How to select the black lines, fill in random colors? (http://forum.oberonplace.com/showthread.php?t=6015)

sy168 15-08-2008 21:32

How to select the black lines, fill in random colors?
 
1 Attachment(s)
How to select the black lines, fill in random colors?
:confused:

shelbym 15-08-2008 23:34

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

sy168 16-08-2008 03:23

Thank you very much, Shelby :D


All times are GMT -5. The time now is 09:20.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com