5 Replies Latest reply on Jun 16, 2010 11:43 PM by sstanleyau

    Active spread and Active page gone? [CS5]

    JeffLambert Level 1

      I'm trying to invoke the active page and active spread in my script and just to test things out trying something very simple like...

       

      tell application "Adobe InDesign CS5"

      get properties of active spread of document 1

      end tell

       

      I get an error, where as

       

       

      tell application "Adobe InDesign CS5"

       

       

      get properties of spread 1 of document 1

      end tell

       

      gets me the proper results

      Same thing with active page. So what happen to those and how can I achieve the same thing without resorting to a lot of lines of codes.

       

      TIA

      Jeff

       

        • 1. Re: Active spread and Active page gone? [CS5]
          JeffLambert Level 1

          Ok, so it doesn't work with this command either in CS4, so bad example, but the following script works in CS4 and not in CS5, so this is what I'm trying to fix if anybody cares to help:-)

           

           

          set theDay to make_two_digit(day of (current date))

          set theMonth to make_two_digit(month of (current date) as number)

          set theYear to year of (current date)

          set theDate to theYear & "-" & theMonth & "-" & theDay as string

          global theDate

          tell application "Adobe InDesign CS4"

          --this line is to make it work on the active layer only

          set myLayer to active layer of layout window 1 of document 1

          set myPage to active spread of layout window 1 of document 1

          try

          set mySlugframe_list to text frame "mySlugFrame" of myPage

          repeat with j from 1 to count of mySlugframe_list

          set mySlugframe to item j of mySlugframe_list

          try

          set mynumber to (((text of cells "6:2" thru "6:2" of table 1 of mySlugframe) as string) as number)

          set mynumberText to (mynumber + 1) as string

           

          --remove the if statement if you need it to be on all layers

          if mySlugframe's item layer = myLayer then

          set text of cells "6:2" thru "6:2" of table 1 of mySlugframe to mynumberText

          set text of cell id 16 of table 1 of mySlugframe to theDate

          end if

          end try

          end repeat

          end try

          end tell

           

           

          on make_two_digit(the_number)

          if the_number is less than 10 then

          set the_result to "0" & the_number as string

          else

          set the_result to the_number as string

          end if

          end make_two_digit

           

          A text frame with a table with the appropriate number of cell and date has to be on the page for it to work. I have a library item that I copy for that but I can't upload it here.

           

          TIA

          Jeff

          • 2. Re: Active spread and Active page gone? [CS5]
            Harbs. Level 6


            I didn't study your code well, but it looks like you are using script labels. In CS5, you can't address script labels directly because it now has a name property.

             

            In Applescript you should be able to write something like 'text frame whose label is "mySlugFrame"' (but I'm not comfortable in Applescript...)

             

            Harbs

            • 3. Re: Active spread and Active page gone? [CS5]
              sstanleyau Level 4

              > something like 'text frame whose label is "mySlugFrame"

               

              Pretty close: text frame 1 whose label "SlugFrame"

              • 4. Re: Active spread and Active page gone? [CS5]
                JeffLambert Level 1

                hmm, that doesn't work either...

                 

                I've changed those lines...

                set mySlugframe_list to text frame 1 whose label "MySlugFrame"

                repeat with j from 1 to count of mySlugframe_list

                set mySlugframe to item j of mySlugframe_list

                 

                also tried

                set mySlugframe_list to text frame 1 whose label is "MySlugFrame"

                 

                nothing works:-/

                 

                Harbs,

                I didn't understand what you mean by label has a name property now and I can't access it like I used to. Can you elaborate a bit on that?

                 

                TIA

                Man do I feel rusted digging in scripting after a couple of years!

                • 5. Re: Active spread and Active page gone? [CS5]
                  sstanleyau Level 4

                  That's what posting before breakfast does. Sorry about the missing "is". If you want all the text frames with that label, use:

                   

                  set mySlugframe_list to every text frame whose label "MySlugFrame"

                   

                  Then mew name property is what you can set in the Layers panel.