I have an InDesign file that I'm trying to script through but I'm running into an issue. I believe a portion of the document's content was created from InCopy because when I try to modify that text frame after scripting through the pages I get a:
I do not have access to InCopy and I've tried overriding the InCopy frames by exporting the INDD file to an IDML file then bringing it back in but I'm unable to bypass InCopy. When I research the site the closest question I was able to find was How to script InDesign/InCopy to “Check In” and “Check Out” textFrames? but when I try to implement checkOut()
onto the selection I get an error so I researched and ran across:
- How to use app.selection[0] for scripts in Adobe InDesign
- Indesign script (Javascript) to return/select words around insertion point
- SELECTED TEXT FORMATTING
but I am still unable to insert on the selection text frame.
Trimmed down code
function run() {
throw new Error( "Script has run into an error" );
}
run.error = null;
try {
app.doScript( somePages );
if ( run.error ) {
throw run.error;
}
} catch(e) {
alert( e );
}
function somePages() {
var allPages = app.documents[0].pages.everyItem().getElements(),
items = app.activeDocument.allPageItems,
pageCount = allPages.length;
for ( var x = allPages.length-1; x >= 0; x-- ) {
if ( allPages[x].textFrames.length != 0 && items[x].locked == false ) {
app.activeDocument.pageItems.everyItem().locked = false;
app.select(allPages[x].textFrames[0].insertionPoints[0]);
app.selection[0].contents= "foobar" + allPages[x].name;
}
}
}
How can I script against a textframe to add text created from InCopy that will allow me to run through the document?