// Resetindex.jsx // This script resets all index entries to the type // currentPage. // WARNING: Do not use this script if you do not want to loose // index entries of another type than currentPage. // This script is mainly intended to revert indexes handled // by Cleanindex.jsx, e.g. for exporting to Word to make // changes/additions to the document without loosing index entries. // If a book is open, all files in the book will be handled, // if no book is open, the active document will be handled. // Made by Teus de Jong, last version August 28, 2005 if (app.books.length == 0){ if (app.documents.length == 0){ errorExit('No documents are open'); } else { nrofdocs = 1; } } else { nrofdocs = app.books[0].bookContents.length; for (i = nrofdocs - 1; i > -1; i--){ app.open(File(app.books[0].bookContents[i].fullName)); } } doc = app.activeDocument; for (d = 1; d <= nrofdocs; d++){ IndIndex = doc.indexes[0]; IndIndex.update(); alltops = IndIndex.allTopics; nroftopics = alltops.length; if (nroftopics == 0){continue} for (i = 0; i < nroftopics; i++){ DoTopic(alltops[i]); } if (d >= nrofdocs){ break; } doc = app.open(app.books[0].bookContents[d].fullName); } function DoTopic(IndTopic){ var i, s; with (IndTopic){ nrofprefs = pageReferences.length; if (nrofprefs < 2){return} for (i = 0; i < nrofprefs; i++){ pageReferences[i].pageReferenceType = PageReferenceType.currentPage; } } } function errorExit(s){ alert(s); exit(); }