Quantcast
Channel: Adobe Community : All Content - InDesign Scripting
Viewing all 8771 articles
Browse latest View live

selection is XML Element

$
0
0

Hi,

 

 

   I need to find selection (Selected Contents) have XML Element (tagged).  Dono how to find that. Can anyone guide me.

 

 

Thanks,

Sudha K


Making a script for Excel files import

$
0
0

HI!

I'm new in scripting. I tryied to make a script, that import every row as table.

But have a problems right from the start...))))

 

I wrote code for Excel file import preferences and for import and place dialog (see below), but I dont understand, how I link a code with import preferences to imported file... How can I do that?

 

-----------

 

function setExcelPrefs () {

   with(app.excelImportPreferences) {

       aligmentStyle = AlignmentStyleOptions.spreadsheet;

       decimalPlaces = 4;

       preserveGraphics = false;

       rangeName = "A1:D1";

       sheetIndex = 1;

       showHiddenCells = false;

   }

}

 

var myDocument = app.documents.item(0);

 

var textFrame = myDocument.pages.item(0).textFrames.add();

myTextFrame.geometricBounds=["6p","6p","24p","50p"];

var myExcelFile = File.openDialog("Choose an Excel file");

myTextFrame.place(myExcelFile);

Remove hyperlink from a TextItem

$
0
0

Hi,

 

I want to insert a hyperlink on some TextItem. That part I know. But sometimes there is already a hyperlink on the textitem I found, and I get the error #79111:

"The object you have chosen is already in use by another hyperlink."

Is there a way to get the hyperlink or the hyperlinkTextSource on that TextItem and to remove it so I can insert a new one? I have thousands of hyperlinks in my file. I don't want to loop through all the hyperlinks in the document to find that particular one each time I get the error.

Here is the code that throw the error:

txtSource = srcDoc.hyperlinkTextSources.add(txtItem, {  name: "txtsrc_" + style + "_" + destName + "_" + idx  });

 

Thanks

OpenType Contextual Alternates

$
0
0

Hi, we ran into a problem with the OpenType feature "Contextual Alternates". When this option is checked, certain search ensigns (dtsearch) don't find the word.

We have for the moment about 100 files with this option checked.

I found a threat which, by scripting, could turn of the ligatures. Is this also possible for the above feature (and to be sure, turning of the ligatures too)?

Thnks

How do I create a script that will apply an object style with a keyboard shortcut?

$
0
0

How do I create a script that will apply an object style with a keyboard shortcut?

A script to apply cell style to entire rows containing a specific text

$
0
0

Hi,

 

I am using InDesign CC 2014

 

Does anyone know how to apply a cellstyle based on text contents found in a cell in javascript?

I need to search the document and change cell style in entire row to "cellStyle01" if the text "someText" appear in cell.

 

I've found similar script here in forum which apply table style, but don't know how to change it to apply cell style!

 

var curDoc = app.activeDocument;
var allTables = curDoc.stories.everyItem().tables.everyItem(); 
app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.findWhat = "someText";
var allFounds = allTables.findText();
app.findTextPreferences = app.changeTextPreferences = null; 
for ( var i = 0; i < allFounds.length; i++ ) {
var curFound = allFounds[i];
if ( curFound.length == 1 ) {
var curFoundParent = curFound[0].parent; 
// curFoundParent.parent.appliedTableStyle = curDoc.tableStyles.itemByName( "tableStyle" ); 
curFoundParent.parent.appliedCellStyle = curDoc.cellStyles.itemByName("cellStyle01"); 
}
}

 

Thanks!

Can you attach a select file into a mail in “Outlook” then send to a specify address?

$
0
0

I have been looking around and trying to find ways to do the following with extendscript:

 

1. Open ‘Outlook’

 

2. Create a new mail

 

3. Attach the files which was selected to a mail then send to a specify address

 

Is this possible?

 

I found this that dose it for MAC but I need to do it in a windows platform

Doubt in Apple Script code during file/folder copy process

$
0
0

Hi,

 

   I have created apple script application for the process to copy files/folder from given source path to destination path. Once files/folders are copied, doing relink process in InDesign files. Src and Destination paths are given in XL.

 

Apple Script Code for this process is working fine.  Then I converted the Code to Apple Script Application and Run the Application by clicking but Its throwing the below error.  I don't know why the application throwing this error, when the code is working fine.

 

Screen shot 2014-07-11 at 2.04.33 PM.png

 

Is there is any other way to protect Apple Script code??

 

Can anyone help me....

 

 

Thanks,

Sudha K


Convert special character number to actual text

$
0
0

Is there an object or property in the documentation that will allow all Current Page Number Markers to be converted to actual text?  The numbers were created by Type -> Markers -> Current Page Numbers and I'm creating a document so when I hand off the .indd files I dont have to worry about them being modified or altered.

Adjusting Script

$
0
0

Hi

I would like to adjust the script: 'ImageCatalog.jsx', so that I can predefine the Document size and orientation before it starts dropping in the thumbnail pics and labels.

Does anyone have any suggestions as to how I could do this?

At the moment it always generates an A4 Portrait document by default.

I'm using Indesign CC.

I've been able to open the script using Extended Script Toolkit, but as a beginner I have no idea what to do from that point!

Thanks

Paste In Place to Specify Master Page

$
0
0

Hi,

 

Can you make a script for  app.pasteInPlace() into master A in all my opening document?

 

I want to paste in place an object to all the opening document's "master A" by script, is that possible?

 

John White

How to order a list of words by increasing (or decreasing) number of letters?

$
0
0

The idea is obtain this:


a

an

at

bar

bis

bus

fish

rules

wolves


It is possible?

 


Remove all unused color in Swatch

$
0
0

I want to remove all unused color in all my opening files, can a script to do this?

Cannot delete the target of an active script event

$
0
0

I am writing a script that uses threeview.

In threeview I add document names (node) and page numbers (item).

I added a button that when clicked adds selected document page to selected frames of the document.

I use "afterSelectionChanged" event which I added to the document. This event calls a function in which I want to place selected PDF document to selected frame.

 

This is the part of the function that is throwing errors:

var mySelection = app.documents.item(0).selection;

for(var myCounter = 0; myCounter < mySelection.length; myCounter++){          

          if (mySelection[myCounter].constructor.name=='Rectangle') {

                        try {

                                    mySelection[myCounter].place(g.doc);

                        } catch (Error) {

                             alert (Error);

                            }

          } else if (mySelection[myCounter].parent.constructor.name=='Rectangle') {

                        try {

                                    mySelection[myCounter].parent.place(g.doc);

                        } catch (Error) {

                                       alert (Error);

                            }

}

All the time I get the message “Cannot delete the target of an active script event”, even dough the

ev.currentTarget before place is [objectDocument].

Please HELP, I have no more ideas!!!

Can you fix scripts problem?

$
0
0

I got these three script, their work very well, but not in the cell, can you fix it:

 

Script 1:

 

00.// left Indent: whatever, firstLineIndent: 8 mm 
01. 
02.var curDoc = app.activeDocument; 
03. 
04.if ( !app.selection.length ) { 
05.    var paras = curDoc.stories.everyItem().paragraphs; 
06.} 
07.else if(app.selection.length == 1 && app.selection[0].hasOwnProperty( “baseline” )) { 
08.        var paras = app.selection[0].paragraphs; 
09.} 
10.else { 
11.    alert(“Something wrong with your selection!”); 
12.    exit(); 
13.} 
14. 
15.paras.everyItem().firstLineIndent = “8mm”; 

 

 

Script 2:

 

01.// left Indent: whatever, firstLineIndent: 0 
02. 
03.var curDoc = app.activeDocument; 
04. 
05.if ( !app.selection.length ) { 
06.    var paras = curDoc.stories.everyItem().paragraphs; 
07.} 
08.else if(app.selection.length == 1 && app.selection[0].hasOwnProperty( “baseline” )) { 
09.        var paras = app.selection[0].paragraphs; 
10.} 
11.else { 
12.    alert(“Something wrong with your selection!”); 
13.    exit(); 
14.} 
15. 
16.paras.everyItem().firstLineIndent = “0mm”; 

 

 

Script 3:

 

01.// left Indent: 8 mm, firstLineIndent: -8 mm 
02. 
03.var curDoc = app.activeDocument; 
04. 
05.if ( !app.selection.length ) { 
06.    var paras = curDoc.stories.everyItem().paragraphs; 
07.} 
08.else if(app.selection.length == 1 && app.selection[0].hasOwnProperty( “baseline” )) { 
09.        var paras = app.selection[0].paragraphs; 
10.} 
11.else { 
12.    alert(“Something wrong with your selection!”); 
13.    exit(); 
14.} 
15. 
16.for ( var i = 0; i < paras.length; i ++ ) { 
17.    var curPara = paras[i]; 
18.    if ( curPara.leftIndent == 0 ) { 
19.        curPara.leftIndent = “8mm”; 
20.    } 
21.    curPara.firstLineIndent = “-8mm”; 
22.} 


Change script function

$
0
0

Can you change the function of script “find-change-by-list“?

 

I want to change in all my opening files.

 

�����-6.jpg

 

main();

function main(){

var myObject;

//Make certain that user interaction (display of dialogs, etc.) is turned on.

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

if(app.documents.length > 0){

  if(app.selection.length > 0){

   switch(app.selection[0].constructor.name){

    case "InsertionPoint":

    case "Character":

    case "Word":

    case "TextStyleRange":

    case "Line":

    case "Paragraph":

    case "TextColumn":

    case "Text":

    case "Cell":

    case "Column":

    case "Row":

    case "Table":

     myDisplayDialog();

     break;

    default:

     //Something was selected, but it wasn't a text object, so search the document.

     myFindChangeByList(app.documents.item(0));

   }

  }

  else{

   //Nothing was selected, so simply search the document.

   myFindChangeByList(app.documents.item(0));

  }

}

else{

  alert("No documents are open. Please open a document and try again.");

}

}

function myDisplayDialog(){

var myObject;

var myDialog = app.dialogs.add({name:"FindChangeByList"});

with(myDialog.dialogColumns.add()){

  with(dialogRows.add()){

   with(dialogColumns.add()){

    staticTexts.add({staticLabel:"Search Range:"});

   }

   var myRangeButtons = radiobuttonGroups.add();

   with(myRangeButtons){

    radiobuttonControls.add({staticLabel:"Document", checkedState:true});

    radiobuttonControls.add({staticLabel:"Selected Story"});

    if(app.selection[0].contents != ""){

     radiobuttonControls.add({staticLabel:"Selection", checkedState:true});

    }

   } 

  }

}

var myResult = myDialog.show();

if(myResult == true){

  switch(myRangeButtons.selectedButton){

   case 0:

    myObject = app.documents.item(0);

    break;

   case 1:

    myObject = app.selection[0].parentStory;

    break;

   case 2:

    myObject = app.selection[0];

    break;

  }

  myDialog.destroy();

  myFindChangeByList(myObject);

}

else{

  myDialog.destroy();

}

}

function myFindChangeByList(myObject){

var myScriptFileName, myFindChangeFile, myFindChangeFileName, myScriptFile, myResult;

var myFindChangeArray, myFindPreferences, myChangePreferences, myFindLimit, myStory;

var myStartCharacter, myEndCharacter;

var myFindChangeFile = myFindFile("/FindChangeSupport/testing001.txt")

if(myFindChangeFile != null){

  myFindChangeFile = File(myFindChangeFile);

  var myResult = myFindChangeFile.open("r", undefined, undefined);

  if(myResult == true){

   //Loop through the find/change operations.

   do{

    myLine = myFindChangeFile.readln();

    //Ignore comment lines and blank lines.

    if((myLine.substring(0,4)=="text")||(myLine.substring(0,4)=="grep")||(myLine.substring(0, 5)=="glyph")){

     myFindChangeArray = myLine.split("\t");

     //The first field in the line is the findType string.

     myFindType = myFindChangeArray[0];

     //The second field in the line is the FindPreferences string.

     myFindPreferences = myFindChangeArray[1];

     //The second field in the line is the ChangePreferences string.

     myChangePreferences = myFindChangeArray[2];

     //The fourth field is the range--used only by text find/change.

     myFindChangeOptions = myFindChangeArray[3];

     switch(myFindType){

      case "text":

       myFindText(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);

       break;

      case "grep":

       myFindGrep(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);

       break;

      case "glyph":

       myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);

       break;

     }

    }

   } while(myFindChangeFile.eof == false);

   myFindChangeFile.close();

  }

}

}

function myFindText(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){

//Reset the find/change preferences before each search.

app.changeTextPreferences = NothingEnum.nothing;

app.findTextPreferences = NothingEnum.nothing;

var myString = "app.findTextPreferences.properties = "+ myFindPreferences + ";";

myString += "app.changeTextPreferences.properties = " + myChangePreferences + ";";

myString += "app.findChangeTextOptions.properties = " + myFindChangeOptions + ";";

app.doScript(myString, ScriptLanguage.javascript);

myFoundItems = myObject.changeText();

//Reset the find/change preferences after each search.

app.changeTextPreferences = NothingEnum.nothing;

app.findTextPreferences = NothingEnum.nothing;

}

function myFindGrep(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){

//Reset the find/change grep preferences before each search.

app.changeGrepPreferences = NothingEnum.nothing;

app.findGrepPreferences = NothingEnum.nothing;

var myString = "app.findGrepPreferences.properties = "+ myFindPreferences + ";";

myString += "app.changeGrepPreferences.properties = " + myChangePreferences + ";";

myString += "app.findChangeGrepOptions.properties = " + myFindChangeOptions + ";";

app.doScript(myString, ScriptLanguage.javascript);

var myFoundItems = myObject.changeGrep();

//Reset the find/change grep preferences after each search.

app.changeGrepPreferences = NothingEnum.nothing;

app.findGrepPreferences = NothingEnum.nothing;

}

function myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){

//Reset the find/change glyph preferences before each search.

app.changeGlyphPreferences = NothingEnum.nothing;

app.findGlyphPreferences = NothingEnum.nothing;

var myString = "app.findGlyphPreferences.properties = "+ myFindPreferences + ";";

myString += "app.changeGlyphPreferences.properties = " + myChangePreferences + ";";

myString += "app.findChangeGlyphOptions.properties = " + myFindChangeOptions + ";";

app.doScript(myString, ScriptLanguage.javascript);

var myFoundItems = myObject.changeGlyph();

//Reset the find/change glyph preferences after each search.

app.changeGlyphPreferences = NothingEnum.nothing;

app.findGlyphPreferences = NothingEnum.nothing;

}

function myFindFile(myFilePath){

var myScriptFile = myGetScriptPath();

var myScriptFile = File(myScriptFile);

var myScriptFolder = myScriptFile.path;

myFilePath = myScriptFolder + myFilePath;

if(File(myFilePath).exists == false){

  //Display a dialog.

  myFilePath = File.openDialog("Choose the file containing your find/change list");

}

return myFilePath;

}

function myGetScriptPath(){

try{

  myFile = app.activeScript;

}

catch(myError){

  myFile = myError.fileName;

}

return myFile;

}

Cancel / OK non-English Buttons

$
0
0

Hi all,

 

As well known when a dialog button string is "OK" or "Cancel" a default action occurs (1 is returned for OK and 2 for Cancel)

Is this true for non-English versions of Indesign?

I would presume let's say on the German version of InDesign on the built-in dialogs one see the terms OK and Abbrechen but does Cancel work? And out of curiosity does "Abbrechen" work?

 

var w = new Window('dialog'),    b1 = w.add('button', undefined, "OK"),    b2 = w.add('button', undefined, "Cancel");
alert((w.show() == 1) ? "OK" : "Cancel");

 

Thanks

 

Trevor

Script UI

$
0
0

If have a button, when click "Button 1",it will pop up second dialog and then click "Button 2", need to pop up third dialog

but can't pop the third dialog, why?

 

w = new Window ("dialog", "Test", undefined, {resizeable: true});

var myText = w.add("edittext", undefined, "", {multiline: true})

myText.alignment = ["fill", "fill"];

myText.minimumSize = [300, 30];

w.location = [55, 140];

myPrinter = w.add("button", undefined, "Button 1");

 

 

var w2 = new Window ("dialog");

w2 .add ("button", undefined, "Button 2");

 

 

var w3 = new Window ("dialog");

w3 .add ("button", undefined, "Button 3");

 

 

myPrinter.onClick = function() {

           w2.show();

           }

w3.onClick = function() {

         w3.show();

}

w.show();

Check the first object within text frame if another text frame or normal text with JaveScript

$
0
0

Hi all,

I need to write script that will check the first object within my selected text frame and tell me if that object is textFrame Object or text Object.

For Example the next image shows that the first object in the main text frame is another text frame contains Table, in that case the script should return TRUE

1.png

in the next case the main text frame contains normal text in beginning of the frame, in that case the script should return FALSE

2.png

So how can i check for this cases,

 

Any help i will be grateful,

 

Thanks

Farsi and Hindi Page numbers

$
0
0

Anyone done Farsi or Hindi Page numbers

On the UI with the ME version there's and option but there's no NumberingStyle for it.

PageNumberStyle.reflect.properties produces

Result: UPPER_ROMAN,

LOWER_ROMAN,

UPPER_LETTERS,

LOWER_LETTERS,

ARABIC,KANJI,

ARABIC_ALIF_BA_TAH,

ARABIC_ABJAD,

HEBREW_BIBLICAL,

HEBREW_NON_STANDARD,

SINGLE_LEADING_ZEROS,

DOUBLE_LEADING_ZEROS,

TRIPLE_LEADING_ZEROS,

__proto__

 

text.digitsType has DigitsTypeOptions.FARSI_DIGITS and DigitsTypeOptions.FULL_FARSI_DIGITS but how can one limit this to just the section page numbering and not all the text digits.

Greps are not an option.

 

I know Harb's done this but I don't know how

 

Thanks in advance

 

Trevor

Viewing all 8771 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>