I've written a script, and it's running so slowly I could almost do it myself at that speed. It's a script to convert text to a table in a special way based on the way the author has typed his document in Word (basically, the author typed a bunch of sentences in Hebrew, followed by a bunch of sentences in English. The script puts these into a side-by-side table). The script just creates a table (adding rows as it goes along), and copies the text from the paragraph to the appropriate cell. It can take it about 30 second to convert 16 lines into a table, really slow. I've run a debug with timing, and the worst offending lines are these: myChars.duplicate (LocationOptions.AT_BEGINNING, myCell); //myChars is the characters to be copied, and myCell the cell to coy them to. (clocks in at over 9,000,000 [what is that, millionths of a second?]) and myChars.duplicate (LocationOptions.AT_BEGINNING, myCell); (clocks in at over 22,000,000!!) Is there anything I can do to improve this? If it helps, here is the complete script: //BSD 9May10 //Turn Following Text into Table: An InDesign CS4 Javascript by Ariel Walden //This script will run through the text following the current cursor location, and turn it into a two column table as follows: //First it will expect to find a run of paragraph styles called "AWFaceToFaceTableHebrew" //These will become the rightmost column of the new table //Then it will expect to find a run of paragraph styles called "AWFaceToFaceTableEnglish" //These will become the leftmost column of the new table //The script will also add a blank line above and below the table, with paragraph style "AWSpace7pt" //No error checking takes place in this script //To run, place the cursor in a blank line (that you have probably added) directly before the run of paragraphs. Double-click the script. myIP = app.selection[0]; //get the current insertion point myIP.contents += "\r"; //add blank line myParas = myIP.paragraphs; myPara = myParas[0]; myPara.appliedParagraphStyle = app.activeDocument.paragraphStyles.itemByName ("AWSpacer7pt"); //set style of blank line myPara = myParas.nextItem(myPara); myTablePara = myPara; //get reference to paragraph in which table will be myTable = myPara.tables.add(LocationOptions.AT_BEGINNING, undefined, {columnCount:2, bodyRowCount:1}); myTable.appliedTableStyle = app.activeDocument.tableStyles.itemByName ("AWFaceToFaceTranslation"); //myTable.bodyRowCount = 1; myRow = myTable.rows[0]; //myTable.columnCount = 2; myTable.columns[0].width = "220pt"; myTable.columns[1].width = "122.992pt"; myPara = myParas.nextItem(myPara); while (myPara.appliedParagraphStyle.name == "AWFaceToFaceTableHebrew"){ myCell = myRow.cells[1]; myCell.appliedCellStyle = app.activeDocument.cellStyles.itemByName ("AWFaceToFaceHebrew"); myChars = myPara.characters.itemByRange(0, myPara.characters.length-2); //remove the hard return at end of paragraph myChars.duplicate (LocationOptions.AT_BEGINNING, myCell); myPara = myParas.nextItem(myPara); myRow = myTable.rows.add(); } myRow = myTable.rows[0]; while (myPara.appliedParagraphStyle.name == "AWFaceToFaceTableEnglish"){ myCell = myRow.cells[0]; myCell.appliedCellStyle = app.activeDocument.cellStyles.itemByName ("AWFaceToFaceEnglish"); myChars = myPara.characters.itemByRange(0, myPara.characters.length-2); myChars.duplicate (LocationOptions.AT_BEGINNING, myCell); myPara = myParas.nextItem(myPara); myRow = myTable.rows.nextItem(myRow); } myTable.rows[-1].remove(); //there will always be a blank line at the end of the table. Remove myIP = myTablePara.paragraphs.nextItem(myTablePara).insertionPoints[0]; myIP.contents = "\r"; //add blank line after table myIP.paragraphs[0].appliedParagraphStyle = app.activeDocument.paragraphStyles.itemByName ("AWSpacer7pt"); Thanks, Ariel
... View more