I need a macro to ungroup large amounts of groups within groups. This is what I have made so far. The problem I am running into is that I can't seem to get it to follow any logic to end the Do loop other then the counter down below but if I do to many step throughs then it errors out the macro. I can't seem to get myself to accept the error. How can I fix what I am doing wrong? Any help would be greatly appreciated.
Dim GroupedShapes As ShapeDim SelectedArea As ShapeRangeDim Variable01 As VariantSet SelectedArea = ActiveSelectionRange
For Each GroupedShapes In SelectedArea Do Until Variable01 = 100 If GroupedShapes.Type = cdrGroupShape Then ab = ab + 1 GroupedShapes.UngroupAll End If Loop Next GroupedShapes
Why would you want a macro to do it. Ctrl+A to select all and then 'Ungroup all'.
Any ways I can try to write a macro for you but you will have to allow me a day as I have not installed DRAW on my home machine.
No that works very well. It wasn't something I saw in my shortcut csv file because it didn't have a shorcut to it. Ctrl+A is Select all for me. Thank you for letting me know about the command. You have saved me a lot of time.
Try this code.
Dim doc As DocumentDim sr As ShapeRangeDim shp As ShapeDim pg As Page
Private Sub UnGroupAll()If CorelDRAW.Documents.Count > 0 ThenSet doc = CorelDRAW.ActiveDocumentFor Each pg In doc.Pages Set sr = pg.SelectableShapes.All For Each shp In sr If shp.Type = cdrGroupShape Then shp.UnGroupAll End If NextNextMsgBox "Ungroup All performed."EndElseMsgBox "No document found open"EndEnd If
Anand Dixit said:Try this code.
Nice... I Hope you don't mind my input.
Also try this. It does the job without activating the pages and uses CQL instead so you don't have to loop through the shapes. It should run very fast.
Dim p As Page
Dim j As Long
For j = 1 To ActiveDocument.Pages.count
ActiveDocument.Pages(j).Shapes.FindShapes(Query:="@type = 'group'").UngroupAll
Why should I mind it John ? It's always great to learn from people like you. Just 5 lines Vs 20, LOL.
Thats the difference between the core programmer and me. I have learned programming by reading VBA books, recording a macro in DRAW and studying it. Its nice to know new things. You are always welcome to correct me. Thank you for sharing and teaching. BTW I like all good things that are free.
© Corel Corporation. The content herein is in the form of a personal web log ("Blog") or forum posting. As such, the views expressed in this site are those of the participants and do not necessarily reflect the views of Corel Corporation, or its affiliates and their respective officers, directors, employees and agents. Terms and Conditions / User Guidelines.