Thanks to Wolfgang’s example and a bit of delving into the API docs, I’ve managed to create a macro that does what I need it to do: select all lines in a document that are the same colour and width as a chosen example line. The code is as follows:
Sub selectSimilar()
document = ThisComponent
selection = document.CurrentSelection
On Error Goto ERR
If (selection.Count>1) Then
MsgBox "Select only one thing"
Exit Sub
End If
exampleShape = selection(0)
drawPage = exampleShape.Parent
If (exampleShape.ShapeType = "com.sun.star.drawing.LineShape") Then
selectLines(drawPage, selection, exampleShape)
End If
document.CurrentController.select(selection)
Exit Sub
ERR:
MsgBox "Select something"
On Local Error Goto 0
End Sub
Function selectLines(drawPage, selection, exampleShape)
numShapes = drawPage.Count - 1
exampleWidth = exampleShape.LineWidth
exampleColor = exampleShape.LineColor
For k = 0 To numShapes
thisShape = drawPage(k)
If (thisShape.ShapeType = "com.sun.star.drawing.LineShape") Then
if (thisShape.LineWidth = exampleWidth AND thisShape.LineColor = exampleColor) Then
selection.add(thisShape)
End If
End If
Next k
End Function