Adobe has long offered users the option of automating InDesign workflows through scripting. Although scripts may be writing in AppleScript (Macintosh only) or VBScript (Windows only), the most satisfactory scripting language is the cross-platform, and very widely used, JavaScript. One of the simplest and yet most useful operations that can be accomplished using scripting is the automation of Find/Change. InDesign’s Find/Change feature is one of the program’s most powerful features and it is one of those features which can be fully automated by scripting. In fact, you can achieve a lot more through scripting than you can by manually performing a Find/Change operation.
There are three main commands available in scripting for performing Find/Change operations: findText(), findGrep() and findGlyph(). A good deal can be accomplished using the straightforward findText() command. However, if you need to make fairly complex changes, and if you have the time and patience to find the right regular expression, you can use the findGrep() command which is designed for performing searches for regular expressions.
Before performing a Find/Change operation, you need to set up the preferences that will be used. Firstly, you set the properties of the findChangeTextOptions object: parameters include caseSensitive, wholeWord, ignoreHiddenLayers and ignoreMasterPages. Next, you set up your findTextPreferences and changeTextPreferences parameters, the most important of which are findWhat and changeTo, respectively. It is also usually a good idea to clear out any preferences that may still be in play from a previous search. This is done by setting both the findTextPreferences and changeTextPreferences objects to nothing, using the commands: app.findTextPreferences = NothingEnum.nothing and app.changeTextPreferences = NothingEnum.nothing.
As well as this, the findTextPreferences and changeTextPreferences objects offer all of the formatting parameters normally available with text objects.
One of the practical exercises which we give to students attending our InDesign scripting courses is to create a script which searches for the name of a company within a document, changes the format of the text to look like a regular web hyperlink (blue, bold, underlined) and then makes it a hyperlink. To change the format of the text, we simply use the appropriate properties of the changeTextPreferences object, such as fillColor, fontStyle and underline.
The writer of this article is a developer and trainer with a UK IT training company offering Adobe InDesign Classes as well as Photoshop training at their central London training centre.
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
