find/change script highlight found text
hello,
i've written script , works great. i'd go through each found word individually (like in find/change dialog button 'find next').
this snippet:
app.findtextpreferences=app.changetextpreferences=null;
var = app.findtextpreferences.findwhat="ensure";
app.changetextpreferences.changeto="make sure";
var found =app.activedocument.changetext();
if (found.length=1){
alert(found.length+" instance of 'ensure' changed");
}else{
alert(found.length+" instances of 'ensure' changed");
}
i want script make each instance of "ensure" active selection can see before change them.
thanks
i believe scripting find/change changes instances in 1 action, making improbable if not impossible select each instance individually before making change.. use like:
var doc = app.activedocument;
var txts = doc.textframes;
var x = 0;
for(c=0;c<txts.length;c++){
words = txts[c].words;
for(c=0;c<words.length;c++){
if(words[c].contents.tolowercase() == "ensure"){
app.selection = words[c];
app.layoutwindows[0].zoompercentage = app.layoutwindows[0].zoompercentage;
if(confirm("do wish change instance?",undefined, "find/replace") == true){
words[c].contents = "make sure";
x++
}
}app.selection = null;
}
}alert(x + " changes made");
though reason run through 1 text frame. maybe or else can fix flaw =)
More discussions in InDesign Scripting
adobe
Comments
Post a Comment