Sorry. my bad. Thanks for helping me. Here's my Data. OOO Folder - Google Drive Here's my code. var myDoc = app.activeDocument; var mySel = app.selection[0]; var allframes = app.activeDocument.allPageItems; var myFound2,myFoundPI2 = []; function rename(){ for(var i = 0 ; i < allframes.length; i++){ if(allframes instanceof Group) allframes.name = "Group"; } } function main(){ rename(); if (app.layoutWindows.length == 0) return; if (app.selection.length != 1 || !app.selection[0].hasOwnProperty('changeGrep')) { alert('chọn cho mình đi'); return; } if (mySel.hasOwnProperty('characters') && mySel.characters.length == 0) return; var style; var scriptVersion = app.scriptPreferences.version; app.scriptPreferences.version = 7.5; var options = app.findChangeGrepOptions.properties; app.findGrepPreferences = NothingEnum.NOTHING; app.changeGrepPreferences = NothingEnum.NOTHING; //cuc ngay try { app.findChangeGrepOptions.properties = ({includeFootnotes:true, kanaSensitive:true, widthSensitive:true}); app.findGrepPreferences.properties = ({findWhat:"~a{1}[\l\u]*?(?=[\\x{322A},\\x{322B},\\x{322C},\\x{322D},\\x{322A},\\x{322B},\\x{322C},\\x{322E},\\x{322F},\\x{3230},\\x{3237},\\x{30FB}])"}); var myFound2= mySel.findGrep(true); for(var a=0;a<myFound2.length;a++){ alert(myFound2.length); for(var b=0;b<myFound2.allPageItems.length;b++){ //alert(myFound2.allPageItems.length); myFoundPI2=myFound2.allPageItems; if(myFoundPI2 instanceof TextFrame){ switch(true){ case(myFoundPI2.parentStory.properties.contents=="1") : { app.select(myFound2); app.changeGrepPreferences.properties = ({changeTo:"\\x{2460}",appliedFont:"A-OTF UD Shin Go Pro", fontStyle:"M",fillColor:"C=100 M=0 Y=0 K=0"}); myFound2.words[0].changeGrep(); break;} } } } } } catch (e) {alert(e + ' at line ' + e.line)} } main(); function getStyleByString(docOrGroup, string, property) { if (string == '[No character style]') return docOrGroup[property][0]; if (string == '[No paragraph style]') return docOrGroup[property][0]; if (string == 'NormalParagraphStyle') return docOrGroup[property][1]; stringResult = string.match (/^(.*?[^\\]):(.*)$/); var styleName = (stringResult) ? stringResult[1] : string; styleName = styleName.replace (/\\:/g, ':'); remainingString = (stringResult) ? stringResult[2] : ''; var newProperty = (stringResult) ? property.replace(/s$/, '') + 'Groups' : property; var styleOrGroup = docOrGroup[newProperty].itemByName(styleName); if (remainingString.length > 0 && styleOrGroup.isValid) styleOrGroup = getStyleByString (styleOrGroup, remainingString, property); return styleOrGroup; };
... View more