1

The following fieldcode in Word displays the contents of the custom document property "myproperty" when it exists; otherwise it does nothing

{IF {DOCPROPERTY "myproperty"} <> "Error! Unknown document property name." {DOCPROPERTY "myproperty"}}

The test for existence is based upon the error message that Word returns if the property does not exist. Trouble is: this error message can be localized (e.g. in French etc).

Do you know how to test for existence of a custom document property in a locale independent manner? This would be equivalent to something like:

{IF {EXIST-DOCPROPERTY "myproperty"}{DOCPROPERTY "myproperty"}}
Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Quiche31
  • 119
  • 10

1 Answers1

0

IMHO you've stumbled over the few issues in Word which are language-content-related and for which no correct solution exists.

Another example is the {STYLEREF} field, which needs a reference to the style you want to refer to. While you have in VAB/VSTO the possibility to refer to the built-in styles through a constant, e.g. wdStyleHeading1, to be language-independent, with the field you must add the style name as "Heading 1" in an English Word. Open the document in a German Word, and you'll get a "style name not defined" error, and vice versa opening a German "STYLEREF "Überschrift 1"} in an English Word.

You haven't said anything about the whole situation in which you want to address your issue. In my document template sets, I'm normally in control of the documents, e.g. there's a global add-in running through which I can control documents. Additionally, templates issued by me do have the custom document properties already defined, so that errors of your kind can not happen. However, even if they're not defined, you may create them while opening a document.

domke consulting
  • 1,022
  • 8
  • 5