View Single Post
Old 03-01-2013, 16:02
nic nic is offline
Join Date: May 2009
Posts: 90
Default Better - uniform fill


this seems to work - the loop is a hash from an older thread re:copying colours to/from outlines/fills.

Im hoping the temp object will not interfere with the process because it is created after the tot variable is set and should therefore never be selected either as (n) or (r n) ?

Sub swapcolors3()
    Dim sr As ShapeRange
    Dim n As Long    ' loop counter
    Dim rn As Long   ' random shape number
    Dim tot As Long  ' total number of shapes
    Dim t As Shape   ' temp shape to hold colour
    Set sr = ActiveLayer.Shapes.All
    tot = sr.Count
    Optimization = True
    'create temp shape
    Set t = ActiveLayer.CreateEllipse2(0, 0, 1)
    For n = 1 To tot               ' loop thru all the shapes in order
    rn = Int(Rnd * (tot)) + 1      ' select a random shape
    'Swap shape(n) and (rn) colours
    'COPY _ to - - - - - - - - - - from
    t.Fill.ApplyUniformFill sr.Shapes(rn).Fill.UniformColor
    sr.Shapes(rn).Fill.ApplyUniformFill sr.Shapes(n).Fill.UniformColor
    sr.Shapes(n).Fill.ApplyUniformFill t.Fill.UniformColor
    Next n
    'delete temp shape
    Optimization = False
End Sub

Last edited by nic; 04-01-2013 at 04:35. Reason: question posed not useful
Reply With Quote