Harbs,
You questioned why I use app.select(). It is the only thing that has partially worked so far,but only for one page. If I try to select more than two pages I get an error saying that the spread cannot be determined.
Trying your latest solution, the one that avoids itemByRange, I get a familiar error as well: "theRange.findGrep() is not a function."
var myDoc = app.activeDocument;
var firstPage = 2;
var lastPage = 4;
var myRange = [];
for(var i=firstPage;i<lastPage;i++){
myRange = myRange.concat(myDoc.pages.item(i).textFrames.everyItem().getElements());
}
var someNumbers = theGrepFinder("\\d{1,3}",myRange);
function theGrepFinder(grepFindIt,theRange){
app.findGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.findWhat = grepFindIt;
var arrGrepFindIt = theRange.findGrep();
return arrGrepFindIt;
}//end theGrepFinder
You need to loop through theRange:
finds=[];
for(i=0;i<theRange.length;i++){
finds = finds.concat(theRange.findGrep());
}
I'll just write the whole thing out...
This should work (untested):
var myDoc = app.activeDocument;
var firstPage = 2;
var lastPage = 4;
var myRange = [];
for(var i=firstPage;i<lastPage;i++){
myRange = myRange.concat(myDoc.pages.item(i).textFrames.everyItem().getElements());
}
var someNumbers = theGrepFinder("\\d{1,3}",myRange);
function theGrepFinder(grepFindIt,theRange){
app.findGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.findWhat = grepFindIt;
var retVal=[];
for(var i=0;i<theRange.length;i++){
retVal =retVal .concat(theRange.findGrep());
}
return retVal;
}//end theGrepFinder
Harbs