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 07-02-2012, 01:40
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 434
Default X5 reselecting a group of objects

If I have some objects selected and I duplicate them then the duplicate group is automatically selected. That's fine, but after I've finished with the duplicate how can go back to my previous selection? Something to do with creating a shaperange before creating the duplicate, I guess, but what I've tried hasn't worked. Thanks,

Chris
Reply With Quote
  #2  
Old 07-02-2012, 11:13
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 ShapeRange

You are correct, the key is to make a ShapeRange of the selected shapes so that you may create a selection from it. A simple example:
Code:
Sub RememberSelection()
    Dim srOrig As ShapeRange, srDuplicate As ShapeRange
    
    Set srOrig = ActiveSelectionRange
    Set srDuplicate = srOrig.Duplicate
    
    srOrig.CreateSelection
End Sub
Hope that helps,

-Shelby
Reply With Quote
  #3  
Old 07-02-2012, 21:31
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 434
Default

Thanks, I've got my macro working but can you tell me why this doesn't work:

Code:
Sub rememberShape()

Dim sr As ShapeRange, sd As Shape

Set sr = ActiveSelectionRange
Set sd = ActiveSelection.Duplicate

sd.AlignToPageCenter (cdrAlignVCenter)
sd.AlignToPageCenter (cdrAlignHCenter)

sr.CreateSelection

End Sub
Cheers,

Chris
Reply With Quote
  #4  
Old 07-02-2012, 21: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 Remember Selection

Give this version a try:
Code:
Sub rememberShape()

Dim sr As ShapeRange, sd As ShapeRange

Set sr = ActiveSelectionRange
Set sd = sr.Duplicate

sd.AlignToPageCenter cdrAlignVCenter + cdrAlignHCenter
sr.CreateSelection

End Sub
-Shelby
Reply With Quote
  #5  
Old 07-02-2012, 23:07
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 434
Default

Thanks, I understand that using two shaperanges works. My question is why using a shaperange and a shape doesn't work. The range is duplicated and moved to the centre but the original is not reselected. Is this a bug? It feels like one.

Chris
Reply With Quote
  #6  
Old 08-02-2012, 00:09
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 Remember Selection

It is actually not a bug. I am not sure how well I can explain this but I shall try. If you do this:
Code:
Msg ActiveSelection.Duplicate.Type
You will get a reply of type: 8, type 8 is cdrSelectionShape, so you are copying the selection itself. Another way to write this that might be more clear is:
Code:
Dim sel As Shape 
Set sel = ActiveDocument.Selection
I know this can get very confusing. :-) So a good rule of them when it is not working it to see what shape type is being returned. This way you know if you are working with the actual shapes, or the selection. I am sure that is all about as clear as mud, but hey, I tried.

-Shelby
Reply With Quote
  #7  
Old 08-02-2012, 07:37
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 434
Default

Hi Shelby,

mud is clearer! The only thing I can think of is that when duplicating a shape Corel X5 leaves the original selected rather than the duplicate. When duplicating a shaperange it selects the duplicate. If so, this seems inconsistent behaviour and may as well be a bug.

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
Re-group objects after ungrouping PAnderson CorelDRAW/Corel DESIGNER VBA 1 04-03-2010 15:57
VBA import files from folder to single pages and group objects by fill.color jansc CorelDRAW/Corel DESIGNER VBA 4 05-07-2008 15:08
Totally Confused - Group of 1 objects? knowbodynow CorelDRAW/Corel DESIGNER VBA 4 08-03-2006 16:56
selecting objects in a group bloodgroove General 2 19-01-2006 12:11
Need help accessing objects in a group ama CorelDRAW/Corel DESIGNER VBA 5 20-02-2004 11:28


All times are GMT -5. The time now is 02:14.


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