Copy link to clipboard
Copied
Hello!
Me again, writing with Google Translate, i'm sorry!
I'm pretty begins on the subject, hope this forum even for beginners.
If not, tell me and run away ...
Two questions:
A. Theoretically. When should I use "getElements" in addition to "everyItems"?
In. Why this script does not open all my book documents?
(Nothing happens)
if (app.activeBook! = undefined) {
myBook = app.activeBook;
for (var a = 0; a <myBook.bookContents.length; a + +) {
myItem = myBook.bookContents.item (a);
var myS = myBook.bookContents.item (a). status;
if (myS! = "DOCUMENT_IS_OPEN") {
app.open (myItem.filePath);
}
}
}
Thank you!
Copy link to clipboard
Copied
Hello 13177el,
Use the below code, may it help to open the all book contents
Simple code:
if(app.books.length==0)
{
alert("please open the book")
}
var myBook = app.activeBook;
var myBookContents = app.activeBook.bookContents;
for(k=0; k<myBookContents.length; k++)
{
var myTotalContents = myBookContents
.fullName.toString() app.open(File(myTotalContents))
}
For question A:
getElements(): Used to store the some values in the variable like
app.activeDocument.paragraphStyles.everyItem().getElements()
app.activeDocument.characterStyles.everyItem().getElements()
app.activeDocument.objectStyles.everyItem().getElements()
If the above code helps for you, then please click help or correct answers for me.
Thanks
Beginner
Copy link to clipboard
Copied
Thank you!!!
It worked.
(Just now I have to cancel the dialogues of rebounding questions...)
Copy link to clipboard
Copied
Hi! Here is an updated version of that script. Feel free to remove the "book is opened" comment. Was just using it to validate the opened book
Copy link to clipboard
Copied
Hi! Here is an updated version of that script. Feel free to remove the "book is opened" comment. Was just using it to validate the opened book
By @Jaime327835277k0z
Copy link to clipboard
Copied
if (app.books.length == 0) {
alert("Please open the book");
} else {
alert("Book is opened");
}
var myBook = app.activeBook;
var myBookContents = myBook.bookContents;
// Array to store opened documents
var openedDocuments = [];
for (var k = 0; k < myBookContents.length; k++) {
var myTotalContents = myBookContents[k].fullName.toString();
var openedDocument = app.open(File(myTotalContents));
openedDocuments.push(openedDocument);
}
// Now, the opened documents are stored in the 'openedDocuments' array