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 29-01-2012, 08:57
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 434
Default X5 - select objects actually on the page

What is the simplest way to select all objects on a page without including all those on the desktop?

Code:
dim s as Shape

For Each s In activepage.Shapes
s.AddToSelection
Next s
For some reason this selects items on the desktop. I don't understand the logic. Surely the desktop should be separate from the activepage?
Reply With Quote
  #2  
Old 29-01-2012, 14:59
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,790
Blog Entries: 13
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 Shape on Desktop

Alright I will give you two ways to do this. The first is simply to remove the shapes on the desktop from all the shapes. You can do this like this:
Code:
Sub SelectAllExcludeDesktop()
    Dim sr As ShapeRange
    
    Set sr = ActivePage.Shapes.All
    sr.RemoveRange ActiveDocument.MasterPage.Layers("Desktop").Shapes.All
    
    sr.CreateSelection
End Sub
As you can see we create a shape range with all the shapes, then simply remove the shapes that are on the desktop layer. Pretty simple, but can we make it even simpler. Of course we can with a little CQL. :-)
Code:
Sub SelectAllExcludeDesktopCQL()
    ActivePage.Shapes.FindShapes(Query:="!@com.layer.name = 'desktop'").CreateSelection
End Sub
At first look you might say, wait, you are saying find shapes equal to 'desktop', notice the exclamation point at the beginning of the CQL statement, this is the not operator, meaning to select all shapes that are NOT on the desktop layer. So you could actually write the statement like this and get the same results:
Code:
Sub SelectAllExcludeDesktopCQL()
    ActivePage.Shapes.FindShapes(Query:="not@com.layer.name = 'desktop'").CreateSelection
End Sub
or you could also do it this way:
Code:
Sub SelectAllExcludeDesktopCQL()
    ActivePage.Shapes.FindShapes(Query:="@com.layer.name <> 'desktop'").CreateSelection
End Sub
However, it is much more common to use the exclamation point. Hope that helps,

-Shelby

Last edited by shelbym; 29-01-2012 at 15:02.
Reply With Quote
  #3  
Old 29-01-2012, 20:22
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 434
Default

Thanks for the alternatives, Shelby. After posting I came up with this:

Code:
For Each l In p.Layers
    For Each s In l.Shapes
    If l.Name <> "Desktop" Then s.AddToSelection
    Next s
Next l
But what is the logic of having the desktop on the active page - I feel it is idiotic, and I don't use the word lightly. Surely the page and the desktop should be separate? Can you explain why they are not? Thanks again,

Chris
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
Select all items on current page (within print area) fungel Feature requests/wishlist 1 20-10-2010 11:58
Select objects within a shape nic Macros/Add-ons 10 20-08-2010 06:36
Is there a way to select all objects on page..... LGD CorelDRAW/Corel DESIGNER VBA 2 10-11-2006 15:04
How to select objects of the same color? Alex FAQ 6 08-07-2005 00:42
Select objects inside another shelbym CorelDRAW/Corel DESIGNER VBA 1 25-11-2003 17:01


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


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