8 Replies Latest reply on May 8, 2009 11:31 AM by deltaek

    Modify script for row height

    deltaek Level 1

      Years ago, I was given this script:

       

      myDoc = app.activeDocument;
        myStyle = myDoc.paragraphStyles.item("•Price");
        app.findPreferences = null;
        app.changePreferences = null;
        myParas = myDoc.search("",false,false,undefined,{appliedParagraphStyle:myStyle});
        for (var j = myParas.length - 1; j >= 0; j--) {
        myParas[j].parent.width = .33;
        }
      Does anyone know how to modify this so I can change row heights to specific atleast heights in my table based on character styles? I only have three character styles. All three would have a different height. Using CS3. Thank you.
        • 1. Re: Modify script for row height
          sudar1983_14 Level 2

          Hi,

           

          Im just modifying your script according to CS3, that it!!!!!

           

          myDoc = app.activeDocument;

            myStyle = myDoc.paragraphStyles.item("•Price");

            app.findTextPreferences = null;

            app.changeTextPreferences = null;

            app.findTextPreferences.appliedCharacterStyle=myDoc.characterStyles.item("cell");

            myParas = myDoc.findText();

            for (var j = myParas.length - 1; j >= 0; j--) {

            myParas[j].parent.width = .33;

            }

           

           

          Regards,

          sudar

          1 person found this helpful
          • 2. Re: Modify script for row height
            sudar1983_14 Level 2

            Hi,

             

            2nd line not needed

             

            myStyle = myDoc.paragraphStyles.item("•Price");

             

             

            regards,

            sudar

            • 3. Re: Modify script for row height
              deltaek Level 1

              I used your suggestion to try to achieve the results I was looking for but ran into trouble. I don't know scripting but thought I could figure it out by your suggestion. I altered it this way:

              ---------------

               

               

              myDoc = app.activeDocument;

               

                app.findTextPreferences = null;

               

                app.changeTextPreferences = null;

               

                app.findTextPreferences.appliedCharacterStyle=myDoc.characterStyles.item(“style1”);

               

                myParas = myDoc.findText();

               

                for (var j = myParas.length - 1; j >= 0; j--) {

               

                myParas[j].parent.width = .8382;

               

                }

               

               

              ----------------

              I put this in script editor and it return an error of "Syntax error. Expected expression, property or key form, etc. but found unknown token."

               

              I was trying to use my "style1" Charater style and assign a height of .8382". For one, it isn't a width but a height. So, I think I did that wrong. And since there is only one table maybe I don't need the "width" at all. Is the "myParas.length actually the height. Next, in the syntax error highlighted the "." in the first line and returned the error.

               

              Sorry I don't really know what to do.

              • 4. Re: Modify script for row height
                Dave Saunders Level 4

                You have "smart" quotes around "style 1" -- dumb them down.

                 

                Dave

                1 person found this helpful
                • 5. Re: Modify script for row height
                  deltaek Level 1

                  Fixed the quotes but it is still not working. Any additional help would be great.

                  • 6. Re: Modify script for row height
                    sudar1983_14 Level 2

                    In CS3 / Windows / Javascript

                     

                    Without any errors, the following code fine,

                     

                    myDoc = app.activeDocument;

                     

                      app.findTextPreferences = null;

                     

                      app.changeTextPreferences = null;

                     

                      app.findTextPreferences.appliedCharacterStyle=myDoc.characterStyles.item("style 1");

                     

                      myParas = myDoc.findText();

                     

                      for (var j = myParas.length - 1; j >= 0; j--) {

                     

                      myParas[j].parent.width = .8382;

                     

                      }

                     

                    regards,

                    sudar

                    • 7. Re: Modify script for row height
                      Dave Saunders Level 4

                      What state are your findChange options? You're not addressing them and they can really screw up a search.

                       

                      I use this to set up a find change:

                       

                      function setupFindText(find, change, wholeWd, caseSense, foots, hidLayers, lockedLayers, lockedStories, masters) {
                          app.findTextPreferences = null;
                          app.changeTextPreferences = null;
                          try { app.findTextPreferences.findWhat = find } catch(e) {};
                          try {app.changeTextPreferences.changeTo = change } catch(e) {};
                          app.findChangeTextOptions.properties = {
                              caseSensitive:(caseSense == null ? false : caseSense),
                              wholeWord:(wholeWd == null ? false : wholeWd),
                              includeFootnotes:(foots == null ? false : foots),
                              includeHiddenLayers:(hidLayers == null ? false : hidLayers),
                              includeLockedLayersForFind:(lockedLayers == null ? false : lockedLayers),
                              includeLockedStoriesForFind:(lockedStories == null ? false : lockedStories),
                              includeMasterPages:(masters == null ? false : masters)
                          }
                      } // end setupFindText

                       

                      Dave

                      • 8. Re: Modify script for row height
                        deltaek Level 1

                        Not sure what you mean since I don't know much about scripting. What I intended to do was find all instances of "cell style 2" in the cell style option. Finding this would give me the row that the height (not the width in my sample script) and then change that to a row height of .0417. I thought I could just adjust the script that I had to make these changes but I think this is more difficult than I expected--for me.