Macro to create fixed(!) serial IDs

For writing a requirement specification document (using writer 3.5) I would like to assign each requirement a fixed serial ID such as R0223, R0224 etc.

It is important to avoid any automatic update of that ID (for example by inserting a new requirement before an existing one) since other external documents refer to that ID. So obviously it does not make sense to use any field variables (e.g. number range) or numbering styles.

I don’t know much about macros, but to me it sounds like this would be the right way to implement this function. My naive idea (algorithm?) was as follows:

  1. Add a custom property called “Counter” (File->Properties->Custom Properties->Add) with type Number and initiate it with the serial ID start number (e.g. 223).
  2. When a new requirement ID is needed the macro simply inserts the custom property field of Counter in the document (as I would do it manually via Insert->Fields->Other->DocInformation->Custom).
  3. Next, the macro cuts the inserted field and uses paste special to insert it as unformatted text so that the value is fixed.
  4. Finally, the macro increases the value of the custom property “Counter” by 1.

Sounds easy, but recording a macro like this did not work simply because any change to a custom property value is not recorded. So I created my own macro source code using the famous copy & paste and trial & error technique. I reached a point where I could output the custom properties but here my mental capabilities stop.

Does anyone have an idea why recording a macro ignores changes of a custom property value or is there a chance to get a source code examples?

Thanks a lot in advance!

It would be much easier to search for a solution if you could provide your macro code.

Unfortunately uploading an attachment requires karma > 3. Anyway, that macro only contained recorded actions for the above step 2 (inserting a field) and 3 (converting field to unformatted text). Any support for creating a macro that increases the value of a custom property field would be great.

Hi @wolfgang,

Any support for creating a macro that increases the value of a custom property field would be great.

Have you found an Answer to your question?

… If not found then read chapter “5.18.3. Master Fields” of “Useful Macro Information For OpenOffice.org By Andrew Pitonyak” (routines posted by Rodrigo V Nunes - Listing 5.50: Setting document variables.)