Scripting



Scripting in InDesign

Scripting is a great tool for performing a variety of tasks. A script can be as simple as an automated common task or as complex as an entire new feature. You can create your own scripts, and you can run scripts that other people have created. For more information on scripting, see the Scripting Guide in the Adobe InDesign Technical Info folder on the InDesign DVD. You can also find the Scripting Guide, scripting requirements, and other developer resources at www.adobe.com/go/scripting_id.

The Scripting Guide contains an introduction to scripting and tutorials. The Technical Info folder also includes a number of useful scripts that you can run, such as a script that draws guides around the selected object. Some of these scripts appear by default in the Scripts panel.

Scripts panel and Script Label panel overview

InDesign includes two panels for scripting: the Scripts panel and the Script Label panel.

The Scripts panel is where you run scripts without leaving InDesign. The Scripts panel displays the scripts that are located in the Scripts folders in the InDesign application folder and in your Preferences folders. If you create or receive a script, you can place it in the Scripts Panel folder so that it shows up in the Scripts panel.

Mac OS
Users/[username]/Library/Preferences/Adobe InDesign/[version]/[language]/Scripts/Scripts Panel

Windows XP
Documents and Settings\[username]\Application Data\Adobe\InDesign\[version]\[language]\Scripts\Scripts Panel

Windows Vista
Users\[username]\AppData\Roaming\Adobe\InDesign\[version]\[language]\Scripts\Scripts Panel

You can then double-click a script in the Scripts panel to run it, or you can run scripts using Quick Apply.

The Script Label panel lets you specify a label for a page item, such as a text frame or shape. Specifying labels for page items is especially useful for writing scripts in which you need to identify an object.

For detailed information on adding, running, and editing scripts, see the Scripting Guide in the Adobe InDesign Technical Info folder on the InDesign DVD or on the Adobe website at www.adobe.com/go/scripting_id.

Open the Scripts panel

 Choose Window > Automation > Scripts.

Open the Script Label panel

 Choose Window > Automation > Script Label.

Running sample scripts

You can run these scripts in InDesign:

AddGuides
Adds guides around the selected object or objects.

AddPoints
Adds points to the paths of the selected object or objects.

AdjustLayout
Moves objects by specified distances on right/left pages.

AlignToPage
Aligns objects to specified positions on a page.

BreakFrame
Removes a selected text frame and its contents from a story.

CornerEffects
Re-draws the path of the selected item or items using a variety of corner effects. Corner effects can be applied to selected points on the path.

CreateCharacterStyles
Defines a complete character style based on the selected text.

CropMarks
Adds crop and/or registration marks around the selected object or objects.

ExportAllStories
Exports all stories in a document to a series of text files.

FindChangeByList
Performs a series of common text find/change operations by reading a tab-delimited text file.

ImageCatalog
Places all graphics in a specified folder in a “contact sheet” layout.

LabelGraphics
Adds a caption (containing the filename, file path, XMP description, or XMP author) next to every imported graphic.

LabelGraphicsMenu
Creates a menu item on the Layout context menu. You can use this menu item to add a caption (containing the filename, file path, XMP description, or XMP author) next to the selected graphic or graphics.

MakeGrid
Creates a grid by subdividing or duplicating the selected object or objects.

Neon
Applies a “blend” effect to the selected object or objects.

PathEffects
Changes the position of path points on the selected object or objects to add a creative effect.

PlaceMultipagePDF
Places all pages of a PDF.

SelectObjects
Selects objects on the active spread by their object type.

SortParagraphs
Sorts the paragraphs in the selection alphabetically.

SplitStory
Splits the text frames in the selected story into separate, unlinked text frames.

TabUtilities
Applies tab stops and indents to the selected text.

For more information on installing and using these sample scripts, see the InDesign CS4 Scripting Readme (PDF):

www.adobe.com/devnet/indesign/pdfs/indesign_cs4_scripting_readme.pdf

Enable scripts attached to menus

Script writers can use a special command that allows scripts to be attached to menu commands. For security purposes, InDesign includes a preference that determines whether attached scripts are allowed. If you trust the source of an InDesign document, you can select Enable Attached Scripts so that scripts run whenever you choose the commands to which they’re attached.

  1. Choose Edit > Preferences > General (Windows) or InDesign > Preferences > General (Mac OS).
  2. Select Enable Attached Scripts.
Important: Before opening an InDesign document from a source you don’t trust, deselect the Enable Attached Scripts option.