OberonPlace.com Forums  

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

Thread Tools Search this Thread Display Modes
Old 14-02-2010, 21:48
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default selecting and adding shpes with effects as one...

Before I dive headfirst into this I figured I'd throw it at the forum...(since it's been so quiet here anyways)...lol

I just wanna add shapes to a shaperange, or process them one way or another, shaperange or not, and I want a shape with an effect to be counted as one item. I haven't had much of a chance to mess with it, but I noticed that parsing shapes usually counts the shape as one and the effect(which is a group usually) as another.

Reply With Quote
Old 15-02-2010, 16:37
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default Shapes exercise

Just in case any one wants to follow along and see how shapes get selected, counted, and or added to shaperanges.

You can use the attached file. Attached file contains 6 items but will be counted as 8 as you will see when following code.
The final sub will count them as 6 shapes. It will also group effects to their parent.

Maybe this helps someone.


Sub test() 'returns 8 shapes

Dim s As Shape
Dim sr As ShapeRange
Set sr = ActivePage.Shapes.All
MsgBox sr.Count

End Sub

Sub test2() 'returns 8 shapes

MsgBox ActivePage.Shapes.All.Count

End Sub

Sub test3() 'returns 8 shapes
    Dim s As Shape
    Dim sr As New ShapeRange
    For Each s In ActivePage.Shapes.All
        sr.Add s
    Next s
    MsgBox sr.Count
End Sub

Sub test4() 'returns 8 shapes

MsgBox ActiveSelection.Shapes.Count

End Sub

Sub test5() ' returns 6 shapes - adds effect group shapes and counts em as one.
    Dim s As Shape
    Dim srBegin As ShapeRange ' first sr with all shapes on page
    Dim sr As New ShapeRange ' new and to be final sr
    Dim prevSh As Shape, mainSh As Shape
    Dim i As Integer
    Set srBegin = ActivePage.Shapes.All
    For i = 1 To srBegin.Count
        Set s = srBegin(i)
        If _
            s.Type = cdrArtisticMediaGroupShape Or _
            s.Type = cdrBlendGroupShape Or _
            s.Type = cdrBevelGroupShape Or _
            s.Type = cdrContourGroupShape Or _
            s.Type = cdrCustomEffectGroupShape Or _
            s.Type = cdrDropShadowGroupShape Or _
            s.Type = cdrExtrudeGroupShape Then
            Set prevSh = s
            Set mainSh = s.Previous
            sr.Add s
        End If
    Next i
    MsgBox sr.Count 'how many shapes? should be 6
    'because we wanted to count effect group shapes as 1.
    'make sure we got the right shapes. Delete em to make sure.
    For Each s In sr
    Next s
End Sub
Attached Files
File Type: cdr test.cdr (144.6 KB, 157 views)
Reply With Quote

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
about effects group... 3dvr CorelDRAW/Corel DESIGNER VBA 2 01-07-2009 14:06
How change Color mode used for effects with VBA? igor___ CorelDRAW/Corel DESIGNER VBA 6 22-11-2006 00:44
[s.Effects.LensEffect] is Error hotswin CorelDRAW/Corel DESIGNER VBA 10 29-08-2005 02:00
How to check presence effects? G-Kir CorelDRAW/Corel DESIGNER VBA 3 22-06-2005 06:11
Image effects not working. kaliatech Corel Photo-Paint VBA 1 17-01-2003 13:51

All times are GMT -5. The time now is 05:49.

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