ms-worddocvariable

Docvariable with empty string value


In word, I'm using docvariables to manage pluralization. A VBA macro is changing the value of several docvariables to pluralize / singularize them.

But sometimes I want to use a Docvariable only for enable/disable a 's' suffix.

Problem: I cannot set it to empty string, because it deletes the docvariable. The field displays an error in word.

So I'm searching a way to achieve this, it could be :

Any other workaround would be appreciated.

Thank you


Solution

  • A Document Variable (used in DocVariable field codes) cannot exist if it has no content.

    A possibility would be to also store the space in this DocVariable so that it display s[space] or just [space].

    Otherwise you may need to write this information to a Bookmark (possibly using a Set field) and display the content using a Ref field.