Skip to content

Instantly share code, notes, and snippets.

@mhjb
Created January 30, 2020 23:08
Show Gist options
  • Save mhjb/5f78dee507754f0871891efe2c70d5ba to your computer and use it in GitHub Desktop.
Save mhjb/5f78dee507754f0871891efe2c70d5ba to your computer and use it in GitHub Desktop.
Indesign script: Frees & styles all anchored texts in a document, replacing anchors with the contained text
// Modified from https://community.adobe.com/t5/indesign/release-all-anchored-objects-at-once/td-p/3807944?page=1
var items = app.activeDocument.allPageItems, count = 0
if(confirm("Okay to attempt to free the contents of ~roughly~ " + items.length + " anchored text boxes, styling them as 'Reference'?")) {
while(item = items.pop()) {
if(item.isValid &&
item.hasOwnProperty('anchoredObjectSettings') &&
item.parent instanceof Character &&
item.hasOwnProperty('texts') &&
(t=item.anchoredObjectSettings).isValid) {
var contents = item.texts[0].contents + "\r"
var parent = item.parent
try {
parent.contents = contents
parent.appliedParagraphStyle = 'Reference'
count = count + 1
} catch (error) {
alert(error)
}
}
}
alert('Freed the contents of ' + count + ' anchored text boxes')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment