Calc: How to make a cell always display the 'File name' (Answered successfully)

LibreOffice 6.0.7.3
‘Calc’

How do you insert the Calc document ‘File name’ into a cell?

If I right click on a cell the pop-up UI offers ‘Insert . . .’ but the options do not include ‘Insert File Name’

Is it possible for a newby to set a cell up to always display the document’s ‘File name’ ?

If it is then also, is it possible for the cell to always display the File name without extension ?

EDIT
Answered successfully. See PKG. Don’t forget to double-click the cell.

Double click in the cell, then …

My Calc V 7.1.5 wrongly inserts the template name if I do as described.

@Lupp - using a template automatically sets File -> Properties -> Tab: Description -> Key: Title and that’s in fact the field (and what the field name tells). That’s why I prefer CELL("filename").

I would judge the TextField related things messed up in Calc. The.textfield.URL, however, works correctly, and seems to be the only type actually needed. The date tecxtfield used for Headers an Footers can’ even be set to a reasonable NumberFormat.

Hello,

use

Filename (short): =REGEX(CELL("filename");"[^/#]+(?='#\$)")"
Filename (w/o extension): =REGEX(CELL("filename");"[^/#]+(?='#\$)")

Hi Opaque and PKG, thanks very much for your answers.

Opaque’s answer did not work on my computer (Mint 19.3) but I phoned a colleague and it worked on his (Mint 19.3).
PKG’s answer did not work on my computer: When I expose the drop down menu from ‘Insert’ and rest the pointer on ‘Field’ all three options are greyed-out.

Is the greying-out of these options a clue to what has gone wrong on my Calc program running on my computer ?

EDIT 16:13 Fri 16 Jul '21, made after the Comments below:
PKG: Thanks for your comment. I had indeed failed to double-click the cell. I can therefore confirm that DOUBLE-CLICKING a cell and then > ‘Insert’ (top toolbar) > ‘Field’ > ‘Document Title’ works on Calc running on Mint 19 - and it omits the file extension, just what I wanted.

Such a little thing but I’m so happy! Been trying to do this for years but just never got round to asking on here! Thanks very much. I’m not marking it as solved just yet because a colleague wants to look at Opaque’s REGEX info and possibly ask something about that.

Opaque’s answer did not work on my computer (Mint 19.3) but I phoned a colleague and it worked on his (Mint 19.3).

Sorry - did not crosscheck with Release Notes - function REGEX() has been introduced in LibreOffice Version 6.2. - See LibreOffice 6.2: Release Notes - The Document Foundation Wiki


> When I expose the drop down menu from 'Insert' and rest the pointer on 'Field' all three options are greyed-out.

Then you are not in edit mode and you ignored the introducing “Double click in the cell, then …” of the answer (or type F2 to enter edit mode).