I would like to add a few remarks.
To get the DateTime fields we needn't loop through all the TextFields. The first TextField of DateTime type (supporting the service "com.sun.star.text.TextField.DateTime") we find points to the
common TextFieldMaster of all DateTime fields contained in the document. That object in turn gives access to all its dependent fields via an array object.
The suggestion to use (a) bookmark(s) to point to DateTime fields needing an update now and then is well suitable, but the bookmarks will be shown in the navigator panel, and may cause some irritation probably. There is an alternative to "name" any TextField.
It has an
.Anchor property, and the Anchor is prepared to accept a HyperLink. There are the three String properties HyperLinkURL, HyperLinkTarget, and HyperLinkName. The HyperLinkName can be (slightly mis-)used as a name for the TextField itself without setting an URL or a Target.
See attached example.
===Edit1 2019-03-08 16:15 CET===
Forget it!
Lupp wrote:The HyperLinkName can be (slightly mis-)used as a name for the TextField itself without setting an URL or a Target.
This
seems to work first - and it works as long as the file is open. However, the HyperLinkName isn't saved if not also a link is set.
What I stated otherwise seems to be valid.
On Windows 10: LibreOffice 7.0 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München