Hello, wondering if it is possible to get some help creating a macro that groups objects based on where they are located on the page.
My document size is 24 inches wide X 18 inches high and I need to make 4 groups of objects:
The first group with all the objects/shapes found on the left 6.5 inches of the page.
Second Group with all the objects/shapes found on the section between 6.5 and 12 inches of the page.
Third Group with all the objects/shapes found on the section between 12 and 17.5 inches of the page.
and a 4th group with all the objects/shapes found between 17.5 and 24 inches of the page.
This is for laser engraving, we use CorelDraw X6 and have to do this process manually every time going trough more than 100 pages each time. Very time consuming.
This macro ideally should run through all the pages in the document.
Help with this will be greatly appreciated.
Jose
Try this in VBA Sub FourGroupsEachPage() Dim d As Document, p As Page, s As Shape Dim x1 As Double, x2 As Double, i% Set d = ActiveDocument For Each p In d.Pages For i = 1 To 4 x1 = Choose(i, 0, 6.5, 12, 17.5, 24) x2 = Choose(i + 1, 0, 6.5, 12, 17.5, 24) Set s = p.SelectShapesFromRectangle(x1, p.BottomY, x2, p.TopY, False).Group Next i Next pEnd SubI have many laser engraving clients. Write to me at tv.softlv@gmail.com if you need anything else.Taras
Thank you so much. This worked beautifully.
I really appreciate your help with this.
Easy!Sub DeleteMagentaShapes() Dim p As Page, SR As ShapeRange For Each p In ActiveDocument.Pages Set SR = p.Shapes.FindShapes(Query:="@outline.color.rgb[.r=255 and .g=0 and .b=255]") SR.Delete Next pEnd SubJose, don't you have more difficult tasks?
Hey Taras, Thank you so much! But it is giving me an error in line: For Each p In d.Pages
the error is: Object Required.
What do you think might be happening..
Thanks again
I fixed the code above
Hello Tara, Could you help me modify the code above that searches for magenta outlines and delete them in the document? Wondering if it is possible to instead search for any shape/object the same as the one currently selected and delete that same shape from the entire document. sometimes the selected shapes appear as part of a group on other pages, which should be also deleted keeping the rest of the group intact. Is that doable? I appreciate it beforehand.
Hi JoseWhen someone asks me =Is that doable?=I remember that I received a degree in physics. And for a physicist, the answer to such a question is unambiguous. Yes of course. However, some nuances are possible.
If you need to find circles that are 2 inches in diameter (or between 1 and 2.5 inches), that's one thing. Regarding the ellipse, the task is a little more complicated. I will say that mathematics allows me to compare different parameters. This is all possible, even for complex curves.
Please write to me at tv.softlv@gmail.com what kind of shapes you need to find and delete.
Taras