Article View: adobe.scripting.indesign
Article #15833Re: OpenScriptsFolder.js
From: Olav_Kvern
Date: Fri, 07 Nov 2003 03:23
Date: Fri, 07 Nov 2003 03:23
64 lines
2246 bytes
2246 bytes
Shane--
Not too much, just that it's a bit more explicit. It also shows something nifty--the JavaScript "execute" method. Consider the following:
//OpenLinkFolder.js
//An InDesign CS JavaScript
//
//This script opens the folder containing the selected linked file.
with(app){
if (documents.length != 0){
if (selection.length == 1){
if ((selection[0].constructor.name !="Text")&&
(selection[0].constructor.name != "InsertionPoint")&&
(selection[0].constructor.name != "TextFrame")&&
(selection[0].constructor.name != "TextPath")){
myOpenLinkFolder();
}
else{
alert("The selected object is a text object. Select a graphic and try again.");
}
}
else{
alert("Please select a single graphic and try again.");
}
}
else{
alert("No documents are open. Please open a document, select a graphic, and try again.");
}
}
function myOpenLinkFolder(){
with(app){
switch (selection[0].constructor.name){
case "Rectangle":
case "Oval":
case "Polygon":
case "GraphicLine":
//Frame is selected; get a reference to
//the graphic contained by the frame (if any).
if((selection[0].contentType == ContentType.graphicType)&&
(selection[0].graphics.length > 0)){
myGraphic = selection[0].graphics.item(0);
}
else {
myGraphic = "no graphic";
}
break;
default:
myGraphic = selection[0];
break;
}
if(myGraphic !="no graphic"){
myLink = myGraphic.itemLink;
myFilePath = myLink.filePath;
myFilePath.parent.execute();
}
}
}
Thanks,
Ole
Technical Details
Message-ID:
<2cce41fd.1@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webxReferences:
<2cce41fd.-1@webx.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,42fe0bc86e6e3248 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-11-06 19:38:01 PST From: Olav_Kvern@adobeforums.com Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.scripting.indesign Subject: Re: OpenScriptsFolder.js Message-ID: <2cce41fd.1@webx.la2eafNXanI> Date: Thu, 6 Nov 2003 19:23:38 -0800 References: <2cce41fd.-1@webx.la2eafNXanI> Lines: 64 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit