Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Problem

...

Bookmarks in a custom Word

...

export template

...

can go missing after

...

export in R4J.

...

The problem arises in the folloiwng stuation:

  • A bookmark is created from selected text that includes a trailing white space

...

Root Cause

The trailing space at the end of the line when highlighting is called show/hide paragraph mark which indicates paragraph break. This is one of MSWord's non-printable symbols so it is not included in the content itself during parsing and, therefore, cannot be parsed by the template parser. Due to the way MSWord handles this (see here for further reading), the template parser treats the next line as part of the bookmark since the trailing space was highlighted as well.

If the template statement directly below a bookmark with a trailing white space retrieves a null value, the value for the bookmark is considered null and the bookmark is deleted. When the exported file is generated, this bookmark doesn't exist the same way anymore and, thus, Word drops it.

Solution

Recommended

  • Bookmarks must be created by selecting the word

    .

  • A line of template code follows immediately beneath.

This example illustrates the problem:

...

The first line is the bookmark, highlighted to show that it ends with a trailing white space. Immediately following the bookmark is a line of template code. In this situation, the trailing space interferes with how Word parses the line of code, with the result that the bookmark gets deleted and hence doesn’t appear in the exported file.

Solution

Avoid inadvertently including trailing white space in a bookmark by selecting the text for the bookmark directly (not with double click)

...

Other

...

, making sure the trailing white space is excluded from the highlighted text.