Skip to main content
Participant
April 25, 2012
Answered

Applescript to delete from selected layer and page

  • April 25, 2012
  • 2 replies
  • 1563 views

Hi,

This is part of a bigger script, but this is where I am having the problem. Hopefully very easy to solve, but driving me mad.

I want to delete a text box from the active page only, and only from one layer.

I can get it to work on one layer, but all pages. And on one page, but all layers.

Could someone please help me write the line to select both active page and layer "slug".

Thanks,

Matt

tell application "Adobe InDesign CS5"

activate

          set myDocument to active document

          set myActivePage to the active page of the active window

          set myLayer to layer "Slug" of myDocument

          tell myLayer

    tell myActivePage

       ungroup groups

       delete (every text frame whose contents contains "delete me")

    end tell

          end tell

end tell

This topic has been closed for replies.
Correct answer sstanleyau

You want something like:

       delete (every text frame whose contents contains "delete me" and item layer is myLayer)

2 replies

sstanleyauCorrect answer
Inspiring
April 26, 2012

You want something like:

       delete (every text frame whose contents contains "delete me" and item layer is myLayer)

Participant
April 26, 2012

Great. Thanks.

Inspiring
April 26, 2012

G'day

It's a hassle, isn't it.

I've only got CS2 at home, so I haven't had a chance to test this in CS5 — but you need something like this :

tell application "Adobe InDesign CS5"

    activate

    tell active document

        tell active page of layout window 1

            try

                ungroup groups

            end try

            set theseFrames to (every text frame whose contents contains "delete me")

        end tell

        repeat with thisFrame in theseFrames

            if item layer of thisFrame is layer "Slug" then

                delete thisFrame

            end if

        end repeat

    end tell

end tell

hope that helps

m.