Mobile app version of vmapp.org
Login or Join
Sent7350415

: In InDesign how can you script to detect a locked object? I have an InDesign brochure that I'm trying to script against however I'm running into issues. When I try to script against the

@Sent7350415

Posted in: #AdobeIndesign #Cc2017 #IndesignScripting #Layers #MasterPage

I have an InDesign brochure that I'm trying to script against however I'm running into issues. When I try to script against the 100 page brochure I get an:


Error Number: 11274; Error String: Object is locked


When I go through the three master page layers' there is no locked layer and when I land on a page the Layer Panel still shows no locked layer on the top and child level areas. Thinking it might be a file issue I tried exporting the brochure to an IDML and opening again then saving as a new INDD but the issue still exists.

I've tried scripting:

app.activeDocument.pageItems.everyItem().locked = false;


on all the pages before tying to manipulate the zero text frame with (app.select(allPages[x].textFrames[0]);) through a for loop but the issue still occurs. Thinking it might be a master page issue I've tried:

app.activeDocument.masterSpreads.everyItem().pageItems.everyItem().locked = false;


but I still get the same results. When referencing the InDesign scripting documentation under Working with Layers the selection regarding locking layers is limited.

How can I script through an InDesign document that is producing an object lock or is there a way I can isolate the locked object?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Sent7350415

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ann6370331

Please try

app.activeDocument.allPageItems.everyItem().locked = false;

yearbook.github.io/esdocs/#/InDesign/Document/allPageItems
Normally you need to access pageItems through their page. So your app.activeDocument.pageItems... leads nowhere.

Same thing is valid for the masterspreads. They have pages as sub collection. So your code for that should be:

app.activeDocument.masterSpreads.everyItem().pages.everyItem().pageItems.everyItem().locked = false;


Also I suggest trying to find it visually. This code will walk through all pages and make the locked items magenta. It will also print messages to the ESTK.

function main () {
var doc = app.activeDocument;
for(var i = 0; i < doc.pages.length; i++) {
$.writeln(''I'm on page ' + i);
var page = doc.pages[i];
for(var j = 0; j < page.pageItems.length; j++) {
var item = page.pageItems[j];
if(item.locked === true) {
// do something to the page item so you can
// find it visually
$.writeln('found a locked item');
item.fillColor = doc.swatches[5]; // normally it is magenta
}
}
}
}
main();

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme