More InDesign Scripts I’ve Found to Be Useful

A while ago I wrote a post about some of the InDesign scripts that I’ve found useful. Today I have two more to share.

Base Paragraph Styles on Basic Paragraph:

This script goes through every paragraph style and changes the basedOn attribute from [No Paragraph Style] to [Basic Paragraph]. If the style is already based on something other than [No Paragraph Style], it leaves it alone.

var myDoc = app.activeDocument;
var pStyles = myDoc.allParagraphStyles;
var basicStyle = pStyles[1];
/*end SET-UP*/

var base;
for(var i = 2; i < pStyles.length; i++){
base = pStyles[i].basedOn;
pStyles[i].basedOn = basicStyle;

This is a script that’s incredibly useful when working on initial layouts. Often I’ll get a file that has a lot of paragraph styles, but something will be off, like font size or hyphenation settings. If none of the styles are based on anything, I have to manually change each one. After running this script, I can just change my basic paragraph style and most of the styles will adjust accordingly.

Unassign Empty Frames:

One of my pet peeves is when I get a file that uses empty text frames for text wrapping or as a colored box. This script goes through the document and looks for empty text frames and changes them to unassigned frames.

var myDoc = app.activeDocument;
var s = myDoc.stories;
/*end SET-UP*/

for(var i = 0; i < s.length; i++){
var sText = s[i].textContainers;
for(var j = 0; j < sText.length; j++){
if(sText[j].contents === ""){
sText[j].contentType = ContentType.UNASSIGNED;

If you prefer, you could replace
sText[j].contentType = ContentType.UNASSIGNED;
sText[j].contentType = ContentType.GRAPHIC_TYPE;
which will convert the frames to graphics instead.

This script also comes in handy in minimizing how many fonts are used. My company has very strict policies regarding which fonts can be used, and occasionally the default font within these empty text frames prevents the file from validating. Once the frames are unassigned, that font goes away.


One thought on “More InDesign Scripts I’ve Found to Be Useful

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s