User:Blue.painting/Insert comment with custom presets

Description
This tutorial covers how to write a Basic macro for Writer that inserts a custom comment at the cursor position (in order to for example preset the Author and/or Date fields).

We will use the com.sun.star.text.textfield.Annotation service and the com.sun.star.util.DateTime struct to obtain a time-stamp from the time of execution.

The following macro, which could for instance be linked with a keyboard shortcut, inserts a custom comment at the current cursor position: