Hello, I need Help with this I need to combine These scripts
I need find and select a note through all the text boxes
if (app.documents.length > 0) { var n = prompt('Type a note: ', 'note', 'Select note'); findNote(n); function findNote(n) { var doc = app.activeDocument; var allMyArt = doc.pageItems; var toSelect = Array(); for (var i = 0; i < allMyArt.length; i++) { if (allMyArt[i].note == n) { toSelect.push(allMyArt[i]) }; }; doc.selection = toSelect; }; } else { alert("No Docs"); }
then I need to find a word within the selected boxes and apply a text style
var frames = app.activeDocument.textFrames; for (var j = 0; j < frames.length; j++){ var text = frames[j].textRange; var italicStyle = app.activeDocument.characterStyles["Bold"]; var haystack = text.contents; var needle = /World/gi; /// "/[\(]([^\)\(\r]*)[\)]/gi;" var match; while(match = needle.exec(haystack)){ var start = needle.lastIndex - match[0].length; var end = match[0].length; for (var i = 0; i< end; i++){ italicStyle.applyTo(text.characters[i + start]); } } }
This is a example isnt real :
Thanks, sorry my bad english