Change Page Numbers in Indexes
Hello,
I have a catalog and I have added two pages in the middle of the catalog. Now, because of this two page addition, I need to update the page numbers listed on the indexes with the new page numbers. I only need to increase each of the page numbers by two, but that only starts on a certain point. So, example, on one of the indexes I have, the page numbers 1-70 can remain the same, since the two extra pages were added AFTER page 70. But every number after 70 needs to increase by 2.
I have a find and replace script. I create a table in excel and drop into the document. The script then takes whatever word or number that is listed in Column A and replaces it with what is in Column B. I originally used this script to find and replace product codes in the catalog, and it worked great because all of the product codes were completely unique.
Trying to use this same script to change the page numbers, but it totally backfired. The issue is that the same number will reoccur later in the table, so the script has the table constantly replacing all of the numbers with the first two. So, here's a small sample of my table:
Col A Col B
423 425
422 424
421 423
420 422
But when I run the script, here's what it will turn into:
Col A Col B
423 becomes 425 425
422 becomes 424 424
421 becomes 425 423 becomes 425
420 becomes 424 422 becomes 424
Because it changes the table, all of the corresponding numbers in the document will then change to 425 or 424.
Is there a way to make it so that the script does not change the information in the table that it uses as a reference?
Here is the script below. I did not write it (some very nice person on these forums did) and don't know anything about scripting. ![]()
the_table = app.selection[0].tables[0];
app.findChangeTextOptions = null;
with (app.findChangeTextOptions)
{
caseSensitive = true;
wholeWord = true;
}
app.findTextPreferences = null;
app.changeTextPreferences = null;
for (row=0; row<the_table.rows.length; row++)
{
if (the_table.rows[row].cells[0].contents == '')
continue;
app.findTextPreferences.findWhat = the_table.rows[row].cells[0].contents;
app.changeTextPreferences.changeTo = the_table.rows[row].cells[1].contents;
app.activeDocument.changeText();
}
Thank so much!
