I've used this to select all shapes:
ActivePage.Shapes.All.CreateSelection
but I would really like to select everything Except anything on the Master Page (Guides, desktop, Template, Grid) so I tried to write this but it doesn't work and gives a error:
ActivePage.Shapes.AllExcluding(IsSpecialLayer).CreateSelection
Any ideas how to fix it?
I've found that pressing F1 on a command takes me to the macros help but where can I find more infomation about how these commands are combined?
Hi,
IsSpecialLayer should be a function returning an Array() containing the shapes number to be eliminated...
For instance the next line of code eliminates from selection the shapes 2 and 3.:
1
ActivePage.Shapes.AllExcluding(Array(2, 3)).CreateSelection
So, you must create a variant function (IsSpecialLayer) to iterate between all shapes and 'collect' the ones to be eliminated (from master page, for instance)...
Here the working code to eliminate from selection all shapes in Master Page (layers "Guides" and "Desktop"):
1 2 3 4 5 6 7 8 9 10 11
Function IsSpecialLayer() As Variant Dim sr As ShapeRange, sh As Shape, i As Long, n As Long, shArray() As Variant, No As Long For Each sh In ActivePage.Shapes n = n + 1 If sh.Parent.Name = "Guides" Or sh.Parent.Name = "Desktop" Then ReDim Preserve shArray(0 To i) shArray(i) = n: i = i + 1 End If Next IsSpecialLayer = shArray End Function
If you have other layers on Master Page, of course, you must complete the condition with their names...
I'm afraid if you have a shape on Desktop layer of Master Page it will be also selected... And you are not able to move selection because of that.
I've just tried to clarify the issue asked in the initial post. A different, maybe simpler way, could be the next code:
1 2 3 4
Dim shR As ShapeRange, shM As ShapeRange Set shR = ActivePage.Shapes.All Set shM = ActiveDocument.MasterPage.Shapes.All shR.RemoveRange shM: shR.CreateSelection