1 Reply Latest reply on Sep 5, 2013 4:10 AM by Vamitul

    finding cells containing numbers and applying a cellstyle.

    schiuma24 Level 1

      i need to find every cell that has just a number in it and apply certain cell style, can anyone help me with a js code for this?

        • 1. Re: finding cells containing numbers and applying a cellstyle.
          Vamitul Level 4

          guh....

          just in the last month or so there were at least 3 threads on similat matters.

          here is a quick and dirty one for all the document

           

           

          function main() {
                    var doc = app.activeDocument;
                    app.findGrepPreferences = app.changeGrepPreferences = null;
                    app.findGrepPreferences.findWhat = "\\A\\d+\\Z"
                    var myF = doc.findGrep(),
                              l = myF.length;
                    while (l--) {
                              if (myF[l].parent.constructor.name == 'Cell') {
                                        myF[l].parent.appliedCellStyle = 'NameOfYourCellStyle';
                                        //optional clear the cell overrides, comment out next line if not needed
                                        myF[l].parent.clearCellStyleOverrides()
                              }
                    }
                    alert('All done!\nYou can go outside an play now!')
          
          
          }
          app.doScript('main()', undefined, undefined, UndoModes.entireScript, 'Apply Cell Style to Nr')