1 Reply Latest reply on Mar 26, 2017 9:54 AM by Larry G. Schneider

    search character and apply character style script

    lMarcrest

      I am new to the forums. I directly contacted Qwertyfly... instead of posting my original query to the forum. He suggested that this was a valid forum discussion and helped me with where to post this discussion. Qwertyfly has assisted me with a script to find a bullet in a document and apply a character style – his script works great. The problem is that the parameters of the search have changed. I now need to restrict the search to a selected, text box and/or series of linked, text boxes, as opposed to the entire document. In addition, sometimes the text where the bullet is situated, has been formatted using a variety of styles and then manually, horizontally scaled up to 90%. I need the bullet in its final form to be 100% in horizontal scale. I tried amending the character style to be 100% in horizontal scale, but it didn't work. Any assistance with this is greatly appreciated. This is Qwertyfly's script…

       

      var main = function() {    var doc; 

        if ( app.documents.length > 0 && app.activeDocument.textFrames.length > 0 ) { 

        // Set the value of the word to look for 

        searchWord1 = "•"; 

        // Iterate through all words in the document 

        // and color the words that match searchWord 

        for ( i = 0; i < app.activeDocument.textFrames.length; i++ ) { 

        textArt = activeDocument.textFrames[i]; 

        for ( j = 0; j < textArt.words.length; j++) { 

        word = textArt.words[j]; 

        if ( word.contents == searchWord1 ) { 

        //:word.filled = true; 

        //word.fillColor = wordColor; 

        app.activeDocument.characterStyles.getByName ( "Bullet" ).applyTo ( word ); 

        } 

        } 

        } 

        } 

       

       

       

      var u; 

      main();

       

      As I know virtually nothing about scripts I'm curious about the lines which speak to color. This parameter is not necessary, it can be removed. Marcrest