3 Replies Latest reply on Jul 31, 2017 7:02 AM by bobr39009910

    Select and OK Paragraph Style

    bobr39009910 Level 1

      Hi,

      I have a script I have been using for some time: https://indesignsecrets.com/topic/ignore-anchored-objects

      It does the job well, but it would be great if it would automatically select a certain paragraph style and OK it without my intervention.

      From what I can tell, the lines would fall at the end of the script after the creation of the dialog box and the call to list the paragraph styles.

      I'm not a scripter, but if pointed in the right direction...

      Thanks, Bob

        • 1. Re: Select and OK Paragraph Style
          S Hopkins Adobe Community Professional

          The function myGetParagraphStyleNames is only for the purpose of the dialog box so the user can choose the style she wants to use for the labels.

           

          It sounds as if you want to use a specific paragraph style without having to choose it in the dialog. You can tell the dialog to choose a specific style as the default. You do this by setting the value of selectedIndex (which is currently set to 0--the first item in the list).

             var myLabelStyleDropdown = dropdowns.add({stringList:myStyleNames, selectedIndex:0});

          For example, if you want the paragraph style  to be "Normal" and it is always the fourth one in the list, you could change the line to read:

             var myLabelStyleDropdown = dropdowns.add({stringList:myStyleNames, selectedIndex:3});

           

          The problem is that, depending on the document, the list of paragraph styles will change ("Normal" will not always be the third one in the list).

           

          You can be sure that the default paragraph style for the document will be the second item in the list, so you could use the value of 1 for selectedIndex.

           

          Of course, you could eliminate the need for choosing the paragraph style, and just define the style as part of the script. But that's more than I think you want to deal with at this point. (1. Remove the choice from the dialog, and 2. specify the style by name.)

           

          Hope this gets you started in the right direction.

          • 2. Re: Select and OK Paragraph Style
            bobr39009910 Level 1

            S Hopkins

             

            Since the paragraph style used will always be imported, dragging it to x position at the same time is doable. I don't know how much time I'd be saving at the end, but after I import the style I run four scripts from another script that batch processes them, so maybe a little.

             

            Here's a Flash video (may need full screen for decent resolution) of the process; you will see where I'm trying to save a few seconds/steps: My expedited label image script procedure

             

            The thought of doing away with the dialog altogether had crossed my mind too, but as you correctly state, more than I want to deal with.

             

            Finally, how do I OK the edited dialog?

             

            Looking forward to trying this on Monday. Thanks!

            • 3. Re: Select and OK Paragraph Style
              bobr39009910 Level 1

              S Hopkins

               

              Once I located the correct line and determined the correct value for the style's position once imported and moved, things worked as you described.

               

              BUT, then I started wondering if their was a way to always select the last style in the list since the style is always imported and always last. A few searches seemed to indicate a minus value might work, and indeed -2 does the job (although I have no idea why -2). I tested on a number of documents with a varying number of paragraph styles without fail...but I haven't run across any style groups yet.  ; D

               

              A co-worker and I discussed the possibility of a true/false statement to okay the dialog, i.e., if style x is selected, true, but I decided that was a bit overboard since it's really a simple matter of pressing the enter key.

               

              Instead I created a shortcut key for the script that batch processes the other scripts (Control+S on a Mac). With the shortcut key and two presses of the enter key, everything runs as intended (assuming no image issues which sometimes happens).

               

              Thanks for you help!

               

              Bob