Article View: adobe.scripting.indesign
Article #14852Re: JS beginners help
From: Roy_Marshall
Date: Wed, 14 Jan 2004 10:30
Date: Wed, 14 Jan 2004 10:30
56 lines
2395 bytes
2395 bytes
Thanks again!
I am nearly there with this script. There is one odd line that doesn't seem to work, although the syntax looks ok, and worked on other parts. I have put a remark before the offending line, near the end.
As i said, i am getting a lot more comfortable with JS now, as this sort of Search and place threw up problems in AS.
SCRIPT:-
if (app.selection.length !=0)
{
if (app.selection[0].constructor.name == "TextFrame")
{
myChange();
}
else
{
alert ("The selected item must be the text frame");
}
}
else
{
alert ("Please select a text box to work with");
}
function myChange()
{
alert ("This will format the catalogue");
//myHeading = app.document.paragraphStyles.item("Kidner Headings")
//myBody = app.document.paragraphStyles.item("George Kidner body Text")
myStory=app.selection[0].parentStory;
app.findPreferences = null;
app.changePreferences = null;
myStory.search("Lot No^tVAT^tDescription^tEstimate^p001", false, false, "1");
myStory.search("^tM^t", false, false, "^t");
myStory.search("^p00", false, false, "^p");
myStory.search("^p0", false, false, "^p");
myStory.search(".^t", false, false, ".^t�");
myStory.search(". (", false, false, " (");
myStory.search(")^t", false, false, ").^t�");
myStory.search("��", false, false, "�");
//Sort out headings
myStory.search("^p^t^t^p", false, false, "^p^p~");
myStory.search("~", false, false, "~",{appliedParagraphStyle:"George Kidner body text"},{appliedParagraphStyle:"Kidner Headings"});
//The next line does nothing. It found the ~ character in the line above, but doesn't seem to find the one below
myStory.search("~", false, false, "~");
alert ("Finnished. You now have to check the line endings etc.");
}
Cheers
Roy
Technical Details
Message-ID:
<2ccf45cf.17@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webxReferences:
<2ccf45cf.-1@webx.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f939a,613db9f5b5ffc527 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2004-01-14 02:37:50 PST From: Roy_Marshall@adobeforums.com Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.scripting.indesign Subject: Re: JS beginners help Message-ID: <2ccf45cf.17@webx.la2eafNXanI> Date: Wed, 14 Jan 2004 02:30:39 -0800 References: <2ccf45cf.-1@webx.la2eafNXanI> Lines: 61 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit