function findNote( note , toApply ){ var idoc = app.activeDocument; var text = selection[0]; for (var i = 0; i < idoc.pageItems.length; i++) { pageItemNote = idoc.pageItems; if(pageItemNote.note == note){ idoc.selection = pageItemNote; alert(note + " " + toApply); idoc.characterStyles.getByName(toApply).applyTo( text.textRange, true ); activeDocument.selection = null; } } }; var LnFront = 'Front Text'; var LnBack = 'Back Text'; var PnFront = 'FText'; var PnBack = 'BText'; findNote(LnFront , PnFront); findNote(LnBack , PnBack); Can someone tell me what I am missing here. The runs only the first function "findNote(LnFront, PnFront)", then when run again "findNote(LnBack, PnBack)" tells me the selected is not an object. But is selected as well the correct characterStyle name ??
... View more