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 05-09-2003, 03:13
glennwilton
Guest
 
Posts: n/a
Default Generic code to process all shapes in a document

Hi

I thought Id share this and also see if others in the group would like to add to it.

For a lot of projects I thought id need some code to scan through all the ojbects in
- The current Selection
- The current layer
- The current page
- The entire document

So I wrote this generic code I could copy and paste that would process all shapes, including those in groups and powerclips. I have setup a form with has 4 option buttons in a frame with the above selections . Clicking on the go button will process all the shapes. I can then fine tune this for each project knowing im going over all the shapes. Only downside is for the entire document - objects on the desktop get process multiable times as they are on the same page.

Can anybody suggest any improvements?

Code:
Option Explicit

Private ShapeCount As Integer
Private GroupCount As Integer
Private PowerClipCount As Integer

Private Sub go_Click()
    Dim i As Integer
    ShapeCount = 0 ' This is used to count how many shapes were processed
    GroupCount = 0
    PowerClipCount = 0

    ActiveDocument.BeginCommandGroup "Undo Name" ' a name for the undo group
    
    If Me.OBSelection.Value = True Then DoScan ActiveSelection.Shapes

    If Me.OBCurrentLayer.Value = True Then DoScan ActiveLayer.Shapes
 
    If Me.OBCurrentPage.Value = True Then DoScan ActivePage.Shapes

    If Me.OBDocument = True Then ' Process all shapes in the Document
            For i = 0 To ActiveDocument.Pages.Count
                DoScan ActiveDocument.Pages(i).Shapes
            Next
    End If
    
    MsgBox (ShapeCount - GroupCount) & " Shapes Scanned (" & GroupCount & " Groups and " & PowerClipCount & " powerclips)", vbInformation
    
    ActiveDocument.EndCommandGroup

End Sub

Private Sub DoScan(ss)
    Dim s As Shape
        
    For Each s In ss
        Select Case s.Type
        
            Case cdrTextShape
                ' Do something
            Case cdrRectangleShape
                ' Do something
            Case cdrPolygonShape
                ' Do something
            Case cdrLinearDimensionShape
                ' Do something
            Case cdrEllipseShape
                ' You get the idea
            Case cdrCurveShape
            Case cdrConnectorShape
            Case cdrBitmapShape
            Case cdr3DObjectShape
            Case cdrArtisticMediaGroupShape
            Case cdrBevelGroupShape
            Case cdrBlendGroupShape
            Case cdrContourGroupShape
            Case cdrDropShadowGroupShape
            Case cdrExtrudeGroupShape
            Case cdrGuidelineShape
            Case cdrMeshFillShape
            Case cdrOLEObjectShape
            Case cdrSelectionShape
            Case cdrNoShape
            
            ' DONT REMOVE
            Case cdrGroupShape
                ' Recursive : this will process all objects in the group
                GroupCount = GroupCount + 1
                DoScan s.Shapes
        End Select
        
        ' This will test to see if a shape is a Powerclip,
        ' If so it will process the shapes inside the powerclip
        If Not s.PowerClip Is Nothing Then
            DoScan s.PowerClip.Shapes
            PowerClipCount = PowerClipCount + 1
        End If

        ShapeCount = ShapeCount + 1
    Next s
        
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
Simple Bar code generator Webster Code Critique 2 06-09-2010 01:41
Text ENCODE Craig Tucker CorelDRAW/Corel DESIGNER VBA 10 26-01-2005 13:59
New document creation problem ddonnahoe CorelDRAW/Corel DESIGNER VBA 2 20-11-2004 00:26
Transfer shapes from Draw to Paint; Using CorelScript in VB6 DWGraphics Corel Photo-Paint VBA 1 18-08-2004 20:49
Active document issues.. wbochar CorelDRAW/Corel DESIGNER VBA 2 19-03-2003 15:15


All times are GMT -5. The time now is 00:41.


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