Article View: adobe.scripting.indesign
Article #8395Re: Javascript troubles trying to select and delete a frame
From: Dave_Saunders
Date: Mon, 16 Oct 2006 22:10
Date: Mon, 16 Oct 2006 22:10
29 lines
1919 bytes
1919 bytes
Hi Dewey,
Welcome.
First, to act on something in an InDesign script, you don't have to select it, just reference it.
When you're looking for an object, the basic rule is to look in the object's parent's collection of like objects.
So, for example, the application has a collection of document objects (the opened documents). Of these, the first member (number zero) is the active document.
So,
myDoc = app.documents[0];
You can also use:
myDoc = app.activeDocument;
these two are not quite the same. The first is an object specifier. It always points at the front document even if you change it. The second is a resolved reference. It always points at the same document even if it drifts to the back (close the document and the variable will become undefined).
Now you've marked some rectangles with the label delete. Because the document object has a rectangles collection, see page 682 of the Scripting Reference for CS2, you can use the item() method to get at the label rectangles (when an object doesn't have a name, item("name") returns an object specifier that works with the label).
So, you could just write:
myDoc.rectangles.item("delete").remove();
and that will delete all the rectangles in your document with the label "delete".
Dave
Technical Details
Message-ID:
<3bc1fd12.1@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news.glorb.com!news2.volia.net!news.ecp.fr!news.stben.net!webcrossingReferences:
<3bc1fd12.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,8e366b71b82eba5c X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII-7-bit From: Dave_Saunders@adobeforums.com Newsgroups: adobe.scripting.indesign Subject: Re: Javascript troubles trying to select and delete a frame Message-ID: <3bc1fd12.1@webcrossing.la2eafNXanI> Date: Mon, 16 Oct 2006 15:10:27 -0700 References: <3bc1fd12.-1@webcrossing.la2eafNXanI> Lines: 42 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news.glorb.com!news2.volia.net!news.ecp.fr!news.stben.net!webcrossing