Normal text,
A user field,
A database field,
A table,
A table within that table,
A frame and
A table within that frame.
Code: Select all
Option Explicit
Sub DeleteAllHyperlinks 'In a Writer document
Dim oDoc,enum1,TTs,thisT,i,col,row,oCell,oCur,txt,TFs,thisTF
oDoc = ThisComponent
REM Process normal text.
enum1 = oDoc.Text.createEnumeration
Enumerate(enum1)
REM Process tables.
TTs = oDoc.getTextTables
For i = 0 to TTs.Count-1
thisT = TTs.getByIndex(i)
For col = 0 to thisT.Columns.Count-1
For row = 0 to thisT.Rows.Count-1
oCell = thisT.getCellByPosition(col,row)
oCur = oCell.createTextCursor
txt = oCur.getText
enum1 = txt.createEnumeration
Enumerate(enum1)
Next
Next
Next
REM Process frames.
TFs = oDoc.getTextFrames
For i = 0 to TFs.getCount-1
thisTF = TFs.getByIndex(0)
enum1 = thisTF.createEnumeration
Enumerate(enum1)
Next
End Sub
Sub Enumerate(enum1)
Dim thisPara,enum2,thisPortion
While enum1.hasMoreElements
thisPara = enum1.nextElement
TableCheck:
If thisPara.SupportsService("com.sun.star.text.TextTable") then
If enum1.hasMoreElements then
thisPara = enum1.nextElement
Goto TableCheck
Else Exit Sub
EndIf
EndIf
enum2 = thisPara.createEnumeration
While enum2.hasMoreElements
thisPortion = enum2.nextElement
thisPortion.HyperlinkTarget = ""
thisPortion.HyperLinkURL = ""
Wend
Wend
End Sub