Article View: adobe.scripting.indesign
Article #8640Re: Find/Change text with library asset (JS)
From: Dave_Saunders
Date: Mon, 02 Oct 2006 16:05
Date: Mon, 02 Oct 2006 16:05
26 lines
1683 bytes
1683 bytes
To place a library item inline, you have to select the text (this is one of the few cases where a selection is necessary).
Here's an example. I created a text frame with five em-spaces in it and selected them. Then I ran this script with a single library open:
myLib = app.libraries[0];
myAsset = myLib.assets[-1];
myAsset.placeAsset(app.documents[0]);
And whango-pango, it worked.
You'd have to do something like this:
myLib = app.libraries.item("NameOfLibrary.indl");
myAsset = myLib.assets.item("MyGraphic");
app.findPreferences = app.changePreferences = null;
myFinds = app.documents[0].search(^m^m^m^m^m, false, false, undefined);
for (j = myFinds.length - 1; j >= 0; j--) {
app.select(myFinds[j]);
myAsset.placeAsset(app.documents[0]);
}
That should do it.
Note the need to include the .indl on the library name; it is easy to be confused by the name on the tab not corresponding to the name used in scripting.
Dave
Technical Details
Message-ID:
<3bc1d8b8.0@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeed.freenet.de!news.albasani.net!news.isoc.lu!webcrossingReferences:
<3bc1d8b8.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,1a069e536fac981 X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII-7-bit From: Dave_Saunders@adobeforums.com Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeed.freenet.de!news.albasani.net!news.isoc.lu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Re: Find/Change text with library asset (JS) Message-ID: <3bc1d8b8.0@webcrossing.la2eafNXanI> Date: Mon, 2 Oct 2006 09:05:10 -0700 References: <3bc1d8b8.-1@webcrossing.la2eafNXanI> Lines: 30 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit