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 08-03-2006, 09:24
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 434
Default Totally Confused - Group of 1 objects?

I have a 16 page CorelDraw 12 document. Each page has a piece of clipart (one group of various objects) and a single piece of artistic text grouped together. I just tried the following macro

Code:
Sub ungroup()
    
    Dim p As Page
    
    For Each p In ActiveDocument.Pages
        ActivePage.Shapes.All.CreateSelection
        Dim grp1 As ShapeRange
        Set grp1 = ActivePage.Shapes.All.UngroupEx
    Next p
    
End Sub
After running the macro Draw is telling me that on each page I have:

Group of 1 Objects on Puzzle

Puzzle is the name of the layer. If I ungroup the group of 1 object I end up back where I started with a group of two objects on the page. What am I doing wrong?

What I want to do is ungroup the text and leave the clipart group intact.

Thanks,

Chris (Hunt)
Reply With Quote
  #2  
Old 08-03-2006, 10:24
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

Code:
Sub ungroup()
    
    Dim p As Page
    
    For Each p In ActiveDocument.Pages
        ActivePage.Shapes.All.CreateSelection
        Dim grp1 As ShapeRange
        Set grp1 = ActivePage.Shapes.All.UngroupEx
    Next p
    
End Sub
Could be written as...
Code:
Sub ungroup()
    
    Dim p As Page
    
    For Each p In ActiveDocument.Pages
        ActivePage.Layers.Item("Puzzle").Activate
        ActivePage.Shapes.All.UngroupAll
    Next p
    
End Sub
There is no need to create a selection, just apply the changes directly to the shapes. The only reason you would need to create a selection is if you wanted to recall it later, but since you have ungrouped the shapes, the selection range no longer exists.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #3  
Old 08-03-2006, 10:27
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

Try adding p.Activate before doing anything with the shapes on a page. This ensures that the page is active before you do something. Normally this should be your concern as CorelDRAW should do it autmatically, but there are some issue where this step might be missing which could cause problems.

Code:
Sub Ungroup()
    Dim p As Page
    For Each p In ActiveDocument.Pages
        p.Activate
        ActivePage.Shapes.All.Ungroup
    Next p
End Sub
Reply With Quote
  #4  
Old 08-03-2006, 10:30
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

I just realized something. You are using ActivePage while looping through different pages. This means that if your active page was page 1, looping through other pages will not change the active page (unless you use Activate method I mentioned earlier). You need to use the reference to your page used in the loop, that is, p.

Here is the revised code:

Code:
Sub Ungroup()
    Dim p As Page
    For Each p In ActiveDocument.Pages
        p.Shapes.All.Ungroup
    Next p
End Sub

Last edited by Alex; 08-03-2006 at 10:43.
Reply With Quote
  #5  
Old 08-03-2006, 16:56
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 434
Default

Thanks for the replies. After some testing I realise that some other part of my total code was causing the weird message. I've adjusted it and it seems to be working fine now.

Best wishes,

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
selecting objects in a group bloodgroove General 2 19-01-2006 12:11
Sorting and Grouping Objects by Color Joyce Schneider General 1 12-07-2005 00:34
Glitches with Names of Objects Granite Golem CorelDRAW/Corel DESIGNER VBA 14 01-06-2005 03:38
Need help accessing objects in a group ama CorelDRAW/Corel DESIGNER VBA 5 20-02-2004 11:28
I need to update objects visibility faster NEHovis Corel Photo-Paint VBA 0 18-07-2003 07:54


All times are GMT -5. The time now is 15:23.


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