ich den folgenden Code haben:Wort VBA Shapes Mit Artikel
Sub removeTopAndBottomMostShapesFromActiveDocument()
Dim shape As shape
Dim topShape As shape
Dim bottomShape As shape
Dim pageNum
For pageNum = 1 To ActiveWindow.Panes(1).Pages.Count
Dim highestPoint, lowestPoint
highestPoint = 999999
lowestPoint = -999999
Set topShape = Nothing
Set bottomShape = Nothing
Dim sr As ShapeRange
Set sr = ActiveWindow.Panes(1).Pages(pageNum).Rectangles.Item(1).Range.ShapeRange
sr.Select
For Each shape In sr
If shape.Top < highestPoint Then
Set topShape = shape
highestPoint = shape.Top
End If
If shape.Top + shape.Height > lowestPoint Then
Set bottomShape = shape
lowestPoint = shape.Top + shape.Height
End If
Next
If Not topShape Is Nothing Then
topShape.Delete
End If
If Not bottomShape Is Nothing Then
bottomShape.Delete
End If
Mit Set sr = Activewindow
... ich kann nicht herausfinden, was die .item(1)
tut. Ich habe Textfelder im Word-Dokument, die alle gleich sind. Auf einigen Seiten gibt eine sr.count
von "0", aber wenn ich zu .item(2)
oder .item(3)
ändere, werden die Textfelder auf der spezifischen Seite gefunden. Jede Hilfe wäre willkommen.