I make a selection (top) and then run my macro and though the macro does fine it leaves the selection in this state (bottom) whereby requiring me to deselect and select again
What is my code missing?
Sub BreakDimensions()Optimization = TrueActiveDocument.BeginCommandGroup "BreakDimension" Dim sr As ShapeRange, s As Shape Set sr = ActiveSelectionRange For Each s In sr If Not s.Type = cdrLinearDimensionShape Then s.RemoveFromSelection End If Next s ActiveSelection.BreakApart sr.AddToSelection sr.Group Optimization = False ActiveDocument.EndCommandGroup End Sub
Instead of sr.AddToSelection, try sr.CreateSelection.
again that only leaves the dimensions selected. It needs to select everything that was selected before running the macro
hence sr.AddToSelection
I tried it in mine and it selected everything even though it seemed like it didn't. Move it and see.
So, besides the dimensions do you need moving of some other previous selected shapes?
I did not understand it from your initial post. Wouldn't they be also broken apart? Isn't that important?
If yes you can filter what to be eliminated from sr.shapes (in my code suggestion( acording to some criteria. Name or Object Data like this:
Creating the property:
ActiveDocument.DataFields.Add "ToBeSelected" ActiveShape.ObjectData("ToBeSelected").Value = "True"
And returning/using it: Debug.Print ActiveShape.ObjectData("ToBeSelected")
Initially I would use a macro to create this property to all shapes I would like to be collected in the final group, I would not use selection at all and I would create a shape range using CQL or simply iterate through all shapes and selecting the ones necessary to be used.