Hi,
I changed my current version in the meantime a bit, since the counter did show the wrong results, if you start the script a second time.
// Your settings // --- var SEARCH_PATTERN = '2013'; var CHANGE_PATTERN = '2014'; // Set SEARCH // --- app.findTextPreferences = app.changeTextPreferences = null; app.findChangeTextOptions.includeMasterPages = true; app.findTextPreferences.findWhat = SEARCH_PATTERN; app.changeTextPreferences.changeTo = CHANGE_PATTERN; // Variables // --- var allDocs = app.documents, nDocs = allDocs.length, nFounds = [], counter = 0; // SEARCH ONLY MASTERPAGES IN ALL OPEN DOCS // --- for ( var i = 0; i < nDocs; i++ ) { var curDoc = app.documents[i], target = curDoc.masterSpreads.everyItem().pages.everyItem().textFrames.everyItem(); var allFounds = target.changeText(); for (var n = 0; n < allFounds.length; n ++) { var curFound = allFounds[n]; if (curFound.length != 0) { counter += curFound.length; } } } app.findTextPreferences = app.changeTextPreferences = null; alert( counter + " expressions have been changed." );
Teetan, I have no idea what you try to do with your second script. Please provide clear steps (1,2,3) and maybe a screenshot before / after.
And: Realize that 'undo' is available only per document. So if you have 20 docs open, you must undo in every document, even if we spent a doScript-Function!