Create Text Anchors

This is a simple script for InDesign CS 5.5. It finds all text formatted with character style “Anchor” and creates text anchors from the found text.

Before running the script this character style should exist in the document. In the screenshot below, words in blue are formatted with it.

After running the script, text anchors are created with the names corresponding to the found words.

If you want to use another character style, modify the following lines:

For example, let's say that you want to use character style “Text Destination” in “Hyperlinks” group.

Change these two lines like so:

It is easy to add a dialog box for choosing the character style, but I am not sure if it is a good idea since the user would have to hit an extra return.

Anyway, if someone wants the dialog box, let me know.

Version 2.0

In version 1.0, if an anchor with the same name already exists, it is skipped; in version 2.0, the script created anchors adding incrementing numbers:

Download the script from here.