CorelDRAW X8 Script to Find Objects with Specific Outline and Layer Position
Here's a VBA script for CorelDRAW X8 that will:
- Find objects with outline color CMYK(0,100,100,0)
- Find the bottom-most object in the layer
Sub FindSpecificObjects()
Dim doc As Document
Dim s As Shape
Dim shapesWithRedOutline As New Collection
Dim bottomShape As Shape
Dim firstShape As Boolean
' Get the active document
Set doc = Application.ActiveDocument
' Initialize variables
firstShape = True
' Iterate through all shapes in the active page
For Each s In doc.ActivePage.Shapes
' Check if the shape has an outline
If s.Outline.Type <> cdrOutline Then
' Skip shapes without outline
Else
' Check for CMYK(0,100,100,0) outline color
If s.Outline.Color.Type = cdrColorCMYK Then
With s.Outline.Color
If .Cyan = 0 And .Magenta = 100 And .Yellow = 100 And .Black = 0 Then
shapesWithRedOutline.Add s
s.CreateSelection
End If
End With
End If
End If
' Find the bottom-most shape
If firstShape Then
Set bottomShape = s
firstShape = False
Else
If s.ZOrderPosition < bottomShape.ZOrderPosition Then
Set bottomShape = s
End If
End If
Next s
' Report results
Dim msg As String
msg = "Found " & shapesWithRedOutline.Count & " objects with CMYK(0,100,100,0) outline."
msg = msg & vbCrLf & "Bottom-most object is of type: " & TypeName(bottomShape)
' Select the bottom shape
bottomShape.CreateSelection
' Show results
MsgBox msg, vbInformation, "Search Results"
End Sub
How to Use This Script:
- Open CorelDRAW X8
- Press
Alt+F11 to open the VBA editor
- Go to
Insert > Module
- Paste the code above
- Run the script with
F5 or the Run button
What the Script Does:
- Searches all objects on the active page
- Collects objects with outline color exactly CMYK(0,100,100,0) (pure red)
- Identifies the bottom-most object in the layer (lowest Z-order)
- Selects all matching objects and the bottom object
- Displays a summary message
Notes:
- The script works with vector objects that have outlines
- It checks the exact CMYK values (0,100,100,0)
- The bottom object is determined by Z-order position (lower number = further back)
- The script will select all matching objects and the bottom object
You can modify the CMYK values in the script if you need to search for different colors.