Copy hyperlink in macro calc

I have a hyperlink in my cell. If I take a value as a string and put it in another cell as a string, it stops being a hyperlink. How to do this and keep the hyperlink.

Why are you copying the contents of the cell and not the entire cell? Why not something like

	oSheet = ThisComponent.getSheets().getByIndex(0)
	aRangeAddress = oSheet.getCellRangeByName("E14").getRangeAddress()
	aCellAddress = oSheet.getCellByPosition(1, 1).getCellAddress()
	oSheet.copyRange(aCellAddress, aRangeAddress)
1 Like
Sub insertHyperlinkToCell
	dim oDoc as object, oCell as object, oLink as object, oText as object
	oDoc=ThisComponent
	oCell=oDoc.Sheets(0).getCellByPosition(0,0) 'cell A1
	oLink=oDoc.createInstance("com.sun.star.text.TextField.URL")
	with oLink
		.representation="LibreOffice"
		.URL="http://libreoffice.org"
	end with
	oText=oCell.Text
	oText.insertTextContent(oText.createTextCursor(), oLink, false)
End Sub

source: [Solved] Hyperlink formatting via BASIC macro (View topic) • Apache OpenOffice Community Forum