I have a drawing with 30.000 shapes. and most of them has another circle right in the middle of other circle. (attached image is only a small part of them).
I am not a VBA programmer but I wrote something but nothing is combined:
Sub combineCircleInCircle() Dim kreis As Shape Dim s As Shape Dim combined As Shape Dim xKreis As Double Dim yKreis As Double Dim xs As Double Dim ys As Double For Each kreis In ActivePage.Shapes kreis.GetPosition xKreis, yKreis For Each s In ActivePage.Shapes s.GetPosition xs, ys If xs = xKreis And ys = yKreis Then ActiveDocument.CreateSelection s, kreis Set combined = ActiveSelection.Combine End If Next NextEnd Sub
It tooks still long time with my way.
Is there a way more efficient? I would like to "combine object with same center points"
Try using
Application.Optimization = True
before starting the iterations, followed by
Application.Optimization = False
after...
Here fast code (used separate check of coordinates and their rounding):
Thank you, it is much much faster than my version.