Can someone please help me to create a macro to remove the last shape and its contents in draw,
The Script i am currently trying looks as follows, but does not want to work.|
Sub DeleteLastShape()
Dim oDoc As Object
Dim oPage As Object
Dim oShapes As Object
Dim i As Integer
Dim lastShapeIndex As Integer
oDoc = ThisComponent
For i = 0 To oDoc.getDrawPages().getCount() - 1
oPage = oDoc.getDrawPages().getByIndex(i)
oShapes = oPage.getShapes()
If oShapes.getCount() > 0 Then
lastShapeIndex = oShapes.getCount() - 1
oShapes.remove(lastShapeIndex)
End If
Next i
End Sub
it gives the following error:
BASIC runtime error.
Property or method not found: getShapes.