If all the links are in the
bodytext of a text document opened in Writer, I would use something like the little Sub posted below. If you also need to treat hyperlinks anchored to TexPportions in cells of TextTables or in TextFrames, it's a bit more complicated.
- Code: Select all Expand viewCollapse view
Sub showRemoveDeadLinks()
theDoc = ThisComponent
theBodyText = theDoc.Text
For each para In theBodyText
For Each piece In para
hlU = piece.HyperLinkURL
If hlU<>"" Then
h = FileExists(hlU)
If NOT h Then
piece.String = "[" & piece.String & "(" & hlU & ")dead" &"]"
piece.HyperLinkURL=""
End If
End If
Next piece
Next para
End Sub
===Edit 2019-02-18 01:42 (UCT + 1)===
I had to rectify the code a bit. The " h = ..." and the inner IF were not correctly placed. In consequence a "End If" was missing
(A short test of the Sub was done with LibO V 6.2.0.3 and with AOO V 4.1.5.)
On Windows 10: LibreOffice 6.2 and older versions, PortableOpenOffice 4.1.5 and older, StarOffice 5.2
---
Lupp from München