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.
you are welcome
Is there a chance you could help me out with another issue I am having? I need to find all outlines in the document that are magenta (R:255, G:0, B:255) and erase them. I am now doing it with the find object function and doing it page by page but wondering if this could be automated.
Many thanks in advance.
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
Now it is not giving any error but nothing is deleted, and I double-checked the outlines they are magenta (R:255, G:0, B:255).
Hi Tara thank you again. No error now but it is not deleting anything, I just realized it is looking for a fill not an outline, I fixed it myself.
Thanks Again, you rock!
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.