OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-01-2013, 05:47
nic nic is offline
Member
 
Join Date: May 2009
Posts: 90
Default Swap the colors of shapes

Hi
Im trying to randomly swap the colours of shapes in a document.
The code below is intended to loop through all the shapes and swap colour with a random shape but it fails with "Object variable or with block variable not set" at the line

c = sr(n).Fill.UniformColor '

Any help appreciated.

Thanks
Nic


Code:
Sub swapcolours()

Dim s As Shape
Dim sr As ShapeRange

Dim n As Double    ' loop counter

Dim R As Single    ' random shape
Dim tot As Single  ' total number of shapes

Dim c As Color     ' looping shapes original color
Dim d As Color     ' random shapes original color

Optimization = True
tot = ActivePage.Shapes.Count
Set sr = ActiveLayer.Shapes.All

For n = 1 To tot      ' loop thru all the shapes in order

    R = Int(Rnd(tot)) ' select a random shape

c = sr(n).Fill.UniformColor ' looping shapes color
d = sr(R).Fill.UniformColor ' random shapes color

sr(n).Fill.ApplyUniformFill d
sr(R).Fill.ApplyUniformFill c

Next n

Optimization = False
End Sub
Reply With Quote
 

Tags
color shape swap


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
macro to swap paint & fill colors Jeff Harrison Corel Photo-Paint VBA 1 09-02-2010 23:51
256 colors Nico General 0 26-04-2007 02:10
Change colors cmjmmrp General 0 02-04-2007 07:17
Spot Colors shelbym CorelDRAW/Corel DESIGNER VBA 0 01-10-2005 19:58
CDR12 ?Bug?: HSB Colors zlatev CorelDRAW/Corel DESIGNER VBA 2 22-02-2005 13:21


All times are GMT -5. The time now is 07:10.


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