Created
January 30, 2020 23:08
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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