JavaScript Automation In InDesign: Find And Change
Adobe InDesign has long offered users the option of automating their 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.
The InDesign scripting framework offers three commands 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 your actually perform 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.
To learn more about InDesign training courses, visit Macresource Computer Training, an independent computer training company offering InDesign training courses in London and throughout the UK.
Related posts:
- Using JavaScript To Find And Change In InDesign Scripting Adobe has long offered users the option of automating InDesign...
- The Best Thing You Will Have With Magazine Templates Indesign Magazine layout can be surely a bother compared to composing...
- JavaScript Behaviors Make Life So Easy JavaScript is an easy-to-use programming language which runs client-side (on...
- The Many Ways Of Building Hyperlinks In Dreamweaver All the best Dreamweaver training courses will show you how...
- Controversy Surrounds A University’s Decision To Change Logo When a major university made the decision to design a...
Related posts brought to you by Yet Another Related Posts Plugin.






















































