0

I am not familiar to OpenOffice Basic, but I need a simple macro code for setting document variables (user defined fields accessable under "field commands"/"Variables" in GUI) that I can assign to a button.

Example: I create a button A calling macro sub SetDocVar on a click, while SetDocVar sets the document variable/field MyField to string value "Test".

How does it work?

1 Answers1

0

This is how it works:

Sub SetDocVar
 tmp = ThisComponent.TextFields.createEnumeration
 Do While tmp.hasMoreElements
  tf = tmp.nextElement
  if tf.supportsService("com.sun.star.text.TextField.User") And _
     tf.TextFieldMaster.Name = "MyField" then
     tf.TextFieldMaster.Content = "Test"
  end if
 Loop
 ThisComponent.TextFields.refresh
End Sub