The command ActiveDocument.Pages(1).Shapes.Range.Select doesnot seem to work in word 2010. (It used to work in word 2003).
I need to select all the shapes on a speci
This gets a little dirty as I have to change/restore relative positioning/sizing in order to get absolute page positioning. Also, changing shapes mess up enumeration, so must refer shapes by names:
Sub DeleteEveryPageTopAndBottomShape()
Dim p As Page, r As Rectangle, s As Shape
Dim rvp As WdRelativeVerticalPosition, rvs As WdRelativeVerticalSize
Dim top_s As String, bottom_s As String
For Each p In ThisDocument.ActiveWindow.ActivePane.Pages
top_s = vbNullString
bottom_s = vbNullString
For Each r In p.Rectangles
If r.RectangleType = wdShapeRectangle Then
For Each s In p.Rectangles(1).Range.ShapeRange
rvp = s.RelativeVerticalPosition
s.RelativeVerticalPosition = wdRelativeVerticalPositionPage
s.RelativeVerticalSize = wdRelativeVerticalSizePage
If Len(top_s) Then
If s.Top < ThisDocument.Shapes(top_s).Top Then top_s = s.Name
Else
top_s = s.Name
End If
If Len(bottom_s) Then
If s.Top + s.Height > ThisDocument.Shapes(bottom_s).Top + ThisDocument.Shapes(bottom_s).Height Then bottom_s = s.Name
Else
bottom_s = s.Name
End If
s.RelativeVerticalPosition = rvp
s.RelativeVerticalSize = rvs
Next
End If
Next
Debug.Print "..."
If Len(top_s) Then ThisDocument.Shapes(top_s).Delete
If bottom_s <> top_s Then ThisDocument.Shapes(bottom_s).Delete
Next
End Sub