Skip to content

Instantly share code, notes, and snippets.

@mhjb
Created June 30, 2022 00:09
Show Gist options
  • Save mhjb/8839d43d0cd24ff92c50d1ffd10fe6cc to your computer and use it in GitHub Desktop.
Save mhjb/8839d43d0cd24ff92c50d1ffd10fe6cc to your computer and use it in GitHub Desktop.
// 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'?")) {
if(app.activeDocument.paragraphStyles.item('Reference') == null) {
app.activeDocument.paragraphStyles.add({ name: '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