2 Replies Latest reply on May 9, 2012 11:31 AM by ax1e2l_b3r4a5s6s

    Applescript - Best way to test for the existence of a text frame

    ax1e2l_b3r4a5s6s Level 1

      I have a text frame I want to perform some operations on if it exists (will in some documents, not in others).

       

      I can't assume it exists, or a I get errors when it doesn't using the below.  the script works fine if the frames exist.

       

      repeat with i from (count of listVoucherT) to 1 by -1

                tell application "Adobe InDesign CS5.5"

                          tell the active document

                                    set Text_Frame to the text frame "VOU1"

                                    if (item i of listVoucherC) = "-" then

                                              tell Text_Frame

                                                        set theLines to every line

                                                        move line i to after last word of line (i - 1)

                                              end tell

                                    end if

                                    set Text_Frame to the text frame "VOU2"

                                    if (item i of listVoucherC) = "-" then

                                              tell Text_Frame

                                                        set theLines to every line

                                                        move line i to after last word of line (i - 1)

                                                        set (item i of listVoucherT) to (" " & (item i of listVoucherT))

                                              end tell

                                    end if

                          end tell

                end tell

      end repeat

       

      How would one modify this to not throw an error if the frame(s) are not there???