OberonPlace.com Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 13-08-2003, 11:14
jwknight
Guest
 
Posts: n/a
Default replace objects of certain color

I'm trying to write a macro that selects objects of a certain color and then moves those objects on to a new layer. I'm stuck at the color selection stage. I'm only a beginner on VBA and guess this is faily easy to do. Could anyone help. Many thanks
Reply With Quote
  #2  
Old 14-08-2003, 11:16
jwknight
Guest
 
Posts: n/a
Default

I managed to find a way of doing it. I'm not sure if its the most efficient way. Corel seems to struggle with the code when dealing with a large number of objects.

For Each t In ActivePage.Shapes
t.Outline.Color.ConvertToCMYK
If t.Outline.Color.CMYKBlack < 100 Then
t.Selected = True
CorelScript.MoveToLayer "layer2"
t.Selected = False
End If

Next t
Reply With Quote
  #3  
Old 14-08-2003, 12:39
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
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 VBA Example

Here is a similar approach. This is the VBA version and it will create the layer for you, then move the objects to that layer.

Code:
Sub ProcessAllObjects()
    ColorToLayer ActivePage.Shapes
End Sub

Private Sub ColorToLayer(ss As Shapes)

Dim s As Shape
Dim lr As Layer
Set lr = ActivePage.CreateLayer("ColorOutlines")

For Each s In ss
    If s.Type = cdrGroupShape Then
        ColorToLayer s.Shapes
    Else
        s.Outline.Color.ConvertToCMYK
        If s.Outline.Color.CMYKBlack < 100 Then s.Layer = lr
    End If
Next s

End Sub
Reply With Quote
  #4  
Old 14-08-2003, 12:43
Lev
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by jwknight
I'm not sure if its the most efficient way. Corel seems to struggle with the code when dealing with a large number of objects.
Try to get rid of CorelScript Commands, I hope it would encrease your programme speed
Code:
Sub LayerMoveTest()
Dim t As Shape
Dim lr As Layer
Set lr = ActivePage.Layers("Layer 2")
For Each t In ActivePage.Shapes
t.Outline.Color.ConvertToCMYK
If t.Outline.Color.CMYKBlack < 100 Then t.Layer = lr
Next t
End Sub
Reply With Quote
Reply


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
Find objects by properties Webster CorelDRAW/Corel DESIGNER VBA 8 01-12-2004 18:51
Converting objects color properties jwknight CorelDRAW/Corel DESIGNER VBA 1 23-10-2003 10:03
I need to update objects visibility faster NEHovis Corel Photo-Paint VBA 0 18-07-2003 07:54
color replacer - some ideas Zuk Macros/Add-ons 0 29-04-2003 03:09
VBA Script for CD 11 - Selecting objects with same color Superfreak CorelDRAW/Corel DESIGNER VBA 4 28-01-2003 11:33


All times are GMT -5. The time now is 01:48.


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