Help with a script that detects the content in a cell and apply the cell style to line

Hello


I am trying to add an article to my table formatting script that is a cell with the word 'Budget' (but this can be written as ' Budget:' or ' Budget: (E) "- but without the speech marks) and apply the cell Style - SponsorCells - to all the cells of the whole line. I currently have on what it will, but it does not work:


function checkWhichTable()
{
// ensure the user made a selection
if (app.selection.length != 1)
return null;
var currentTable = app.selection[0];
if (currentTable.hasOwnProperty("baseline"))
{
currentTable = app.selection[0].parent;
}
while (currentTable instanceof Cell || currentTable instanceof Row || currentTable instanceof Column)
currentTable = currentTable.parent;
if (!(currentTable instanceof Table))
{
// No table selected
return null;
}
return currentTable;
}
app.doScript(checkUserSelection, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Process Table");


function checkUserSelection ()
{
var a_table = checkWhichTable();
if (a_table == null)
{
if (confirm("No table selected. Do you want to process *all* tables?") == false)
return;
allTables = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
for (aTable=0; aTable<allTables.length; aTable++)
{
processTable (allTables[aTable]);
}
} else
{
processTable (a_table);
}
}
function processTable(table)
{
// do something here!


//Set 1st Row Height
table.rows[0].height = "30mm";


//Find Text in Cell and apply Cell Style to Row 
var  
  myCellText=['Budget', 'Budget:', 'Budget: (E)'];  
 var myRegEx = new RegExp("^("+myCellText.join("|")+")$");
  for (i=0; i<table.cells.length; i++)
  {
    if (table.cells[i].texts[0].contents.match(myRegEx))
      table.cell[i].appliedCellStyle = "SponsorCells";
  }


//end - do something here!
}  


I can get the script to apply the cell style to "SponsorCells" for each cell that contain the word 'Budget' etc, but I need cell ever on this line to have the cell style applied. I tried to re-write line 56 which applies the style to a cell, but I can't seem to make it work. Any help would be great.


Separate on this issue, I would like to have a line of code similar to the 46 line, which sets the 1st height of lines, but I would like to say "If a cell has 'A cell Style' and then applies the value height 10 mm". If someone could result as a help of bonuses, things would be great double.


Thanks in advance!

But that could be painfully slow. To speed things up, follow these steps:

var cells = table.cells.everyItem().getElements();
for (var i=0; i

It is faster, because it creates an array of cells with a call to table.cells, which is several times faster than calling table.cells. And before assigning to line 12mm height is useful to check if it is already 12 mm. checking things in InDesign and do things only when it is necessary is much more effective than simply doing things even if they are not necessary.

Tags: InDesign

Similar Questions

  • Help with a script that converts the HTML object text box

    I don't know anything about programming scripts and unfortunately inDesign isn't any panel actions as Photoshop..

    I need a script to convert a text box with HTML code inside a HTML object... I think not, it should be very difficult

    How could be the following:

    (1) select the text box
    (2) cut all text inside
    (3) remove the empty box
    (4) select selection tool
    (5) go to OBJECT/INSERT HTML
    6) paste it into the code before you cut the text box
    (7) OK and close the menu INSERT HTML code

    If the Script works, we could change with HTML code inside a text box to an object HTML (video, card, animations,...)

    The first step could be manually selecting each text box or by selecting all of the boxes that start automatically by "< iFRAME '

    1000 thanks

    Remember that you can not get an answer it if you don't show any attempt of your choice.

    FWIW

    Loïc

  • I need help to write a script that detects the first instance of a paragraph style and then change

    I need help to write a script that detects the first instance of a paragraph style and then he goes to a different paragraph style.  I don't necessarily need someone to write all this, by the biggest problem is to find how to find just the first instance of the paragraph style.  Any help would be greatly appreciated, thank you!

    Hello

    then try this with your active doc:

    ....................

    myDoc var = app.activeDocument;

    mStyle var = myDoc.paragraphStyles.item ("PS_NameToFind"); change the name to paraStyle

    var mStyle_1 = myDoc.paragraphStyles.item ("PS_NameToChange"); change the name to paraStyle

    var mFrames = myDoc.pages.everyItem ().textFrames.everyItem () .getElements ();

    app.findTextPreferences = null;

    app.findTextPreferences.appliedParagraphStyle = mStyle;

    for (var k = 0; k)< mframes.length;="">

    {

    currFound = mFrames [k] .findText ();

    If (currFound.length > 0)

    currFound [0] .paragraphs [0] .appliedParagraphStyle = mStyle_1;

    }

    app.findTextPreferences = null;

    ................

    Rgds

  • Help with a script to remove the link "Place and link" content

    Hello

    I need a script that will separate the content that has been placed in an indesign document by using the feature "place and link.

    I know I can manually go to the link Panel, select the linked content here and click 'remove link' in the Panel menu. However, I have about 200 indesign documents that are all full of content that has been 'placed and connected '. One I get a script to unlink content, I can add it to a batch routine to make the record of 200.

    Can anyone help please.

    See you soon

    Like this?

    app.activeDocument.links.everyItem () .unlink ();

  • Girls need help with a script to repeat the link to another folder in indesign

    I REALLY hope you smart people can help me.

    We had servers which means that all of our Indesign documents now have a broken link. To manually "re-edit the link to the file" causes Indesign down :-(. And it takes forever I am hoping to find a script that can connect all the links in the doc to a new file structure.

    The name of the link (name of file) and the file structure remains the same; Just point to another server. The structure contains subfolders so the best way would be that the script can see subfolders as well, but otherwise I would gladly use a script that points of 6 subfolders at a time.

    Problem - I KNOW NOT ALL SCRIPTS and I'm a graphic designer so I can't create scripts :-(. I have already had success Googling a script to unlink everything in the document, but I don't know how to run the script. DO NOT to create them.

    ANY help in this forum? I have 6 designers waiting for me to fix this.

    Is there a script where I could just change the path and then he could repeat?

    We have iMac OSX Yosemite 10.10.4

    PLEASE HELP... :-)

    / Dina

    Try this... it is created by Vamitul

    main() {} function

    var doc = app.activeDocument;

    myLinks var = doc.links.everyItem () .getElements ();

    var linkObj = {};

    Create the initial object

    / * {linkObject

    [path] {missingNr,

    arrayOfMissingLinks}

    } */

    for (var i = 0; i)< mylinks.length;="" i++)="">

    If (myLinks [i] .status == LinkStatus.LINK_MISSING) {}

    var myPath = File(myLinks[i].filePath).path.toString ();

    If (linkObj [myPath] == undefined) {}

    linkObj [myPath] = {}

    missingNr: 1.

    missingLinks: [myLinks [i]],.

    newPath: "

    }

    } else {}

    linkObj [myPath] .missingNr ++;

    linkObj [myPath].missingLinks.push (myLinks [i] .getElements () [0]);

    }

    }

    }

    $.writeln (linkObj.toSource ());

    var myDialog = new window ("dialog", "link Chaser:', undefined");

    Panel1 = myDialog.add var ('panel', undefined, "double-click to select the new path '");

    Panel1. Align = ["fill",""];

    myList var = panel1.add ("listBox", undefined, "", {})

    columnWidths: [160, 160, 130],

    numberOfColumns: 3,.

    showHeaders: true,

    columnTitles: ['old road', 'New Path', 'Nr. missing links']

    });

    myList.size = [450, 200];

    myList.align = ["fill",""];

    for {(var missingPath in linkObj)

    with (myList.add ("item", missingPath)) {}

    Subitems [0] .text is linkObj [missingPath] .newPath;.

    Paragraphs [1] .text is linkObj [missingPath] .missingNr;.

    }

    }

    myList.onDoubleClick = function() {}

    var myNewPath = (new folder (app.activeDocument.filePath) .selectDlg ("Select New Folder") |. toString() ' ");

    myList.selection.subItems [0] .text = myNewPath;

    linkObj [myList.selection.text] .newPath = myNewPath;

    }

    myDialog.add ('button', {undefined, "Ok",

    name: 'ok '.

    });

    myDialog.add ("button", undefined, "Cancel", {})

    name: "Cancel".

    });

    If (myDialog.show () == 1) {}

    for (var i in linkObj) {}

    If (linkObj [i] .newPath! = ") {}

    var fixedNr = 0;

    Var links = linkObj [i] .missingLinks

    for (var j = 0; j)< links.length;="" j++)="">

    var queue = newFile (linkObj [i] .newPath + "/" + links [j] .name);

    If {(newFile.exists)

    fixedNr ++;

    Links [j] .relink (NewFile);

    }

    }

    Alert ("in the folder: \n" + linkObj [i] .newPath + '\n' +)

    'Fixed' fixedNr ' links of ' + linkObj [i] .missingNr + '\n ' +.

    "Please check");

    }

    }

    };

    }

    app.doScript ('main()', undefined, undefined, UndoModes.entireScript, "Chaser link");

  • Need help with custom script to rename the layers

    Hello world.

    I need help to write a custom script (because I suck at it) that will allow me to go through all the layers and sous-calques for a specific name ('X') and give it a new specific name ('Y').

    I have had success using the script below, but it does not work on any text layers names where the text layer was previously particularly well-known in 'X' and now changed needs.

    Any help is greatly appreciated.

    * Note: this script was originally used to find any layer with 'Copy' in its name and remove with anything after (to correct the problem of duplication of layers by adding this text).

    This is why the function is named removeCopy. It works for renaming layers also - just not a layer of text unfortunately.

    #target illustrator

    function removeCopy() {}
    If (app.documents.length == 0) return;
    var app.activeDocument = docRef;
    recurseLayers (docRef.layers);
    }
    removeCopy();
    function recurseLayers (objArray) {}
    for (var i = 0; i < objArray.length; i ++) {}
    ObjArr [i] .name = ObjArr [i].name.replace (/ \s*current name\s*\d*/, 'new name');
    If (objArray [i] .layers) recurseLayers (. layers.length > 0 ObjArr [i]);
    }
    }

    I finally found something after searching forums for a week. My confusion was related to the way Illustrator treats real layers against text/path/object "layers." Instead of layers, I had to use the pageItems in the script. The code below works. Thanks to Gustavo for his answer in another thread and Carlos I thank you for this looking too good! You're great to be ready to help models do more advanced things with Illustrator.

    var doc = app.activeDocument;
    var items = doc.pageItems;
    for (var g = 0; g)
        elements [g] .name = elements [g].name.replace ('Century Schoolbook text line', ' MonogramText: Century Schoolbook ");
    };
    App.Redraw ();
  • Need help with creating table that inserts the lines according to the amount of data

    Hello

    I try to create a table for supervisors to enter their subordinates of information and inserts lines for supervisors with several of his subordinates.  This form is not be connected to a data source, the supervisors will be simply fill out the form and print.  I want it sort of look like this:

    Name Position # Ranking Hours

    I really appreciate any help.  Thank you!

    Hi Laura,

    It's very strange. I downloaded a new version on the site and it works perfectly. The script is in the right place.

    I can sugggest you right click on the download link and select "save a copy as" the alternative menu. This should save the form locally and from there, you should be able to open it in Acrobat.

    If you are a Mac, make sure that the form opens in preview from Apple.

    Also make sure that Javascript is enabled in Acrobat (in the preferences window).

    Niall

  • Help with a Script to remove the additional paths and save

    Here are a few scripts that I have at the moment, but none work. With the first script, I get an error with the 'indexOf', and with the second script, it keeps only the second name listed in the string. How can I get either of these to work where I can remove all the paths, with the exception of multiple ones I want to keep?

    function deletepaths()
    {
      if (!documents.length) return false;
    
    
      var doc = activeDocument;
      var save = ["Ex1", "Ex2", "Ex3"];
    
    
      for (var x = 0; x < doc.pathItems.length; x++)
      {
        if (save.indexOf(doc.pathItems[x].name) == -1))
        {
          doc.pathItems[x].remove();
        }
      }
    }
    deletepaths();
    

    deletepaths();
    function deletepaths(){
    if(!documents.length) return;
    var doc = activeDocument;
    for(var a = doc.pathItems.length-1;a>-1;a--){
    if(doc.pathItems[a].name != ("ex1", "Ex2")) 
         doc.pathItems[a].remove();
      }
    }
    

    IndexOf does not work with extension script. Most likely, you would need a number if statement for many golds ' | ', or a loop in the loop goes well your path names.

  • If anyone can help with a report that retrieves the external ID field in the CRM

    I have an affiliate system where the customer imported 3600 + recordings, some of which were to the eternal ID ("field of your identification on the import file) together and some are not.

    The problem is that I have to update all of the CRM records and impossible to import the changes that I don't know what the original external id value. Catalyst support of business savvy that they can't include this field in a report (don't get started me on that...) and I'm now desperately need a way to get that data on the file and are essential for any news updates via the import of files. I would like to delete all files and start again except that there is no wholesale don't delete option in CRM BC - Yes you can do it in the products but not the CRM or Web Apps...! The only option available in British Colombia is to remove a list of screen at once, but then I have the problem that this issue is not all CRM records - only those whio belong to a secure area.

    My need is urgent, so any free help or otherwise would be approeciated and the solution must be one that allows me to run such export on an irregular basis.

    OK... Thanks to those who feel now offered help and I have a little a goose, but then isn't quite.

    Colombia-British in his usual style of the help documentation, are quite clear in their explanation of the way in which the Unique Id (which is actually the ID ' external ' e CRM under the Misc section). Here is the description from the import of the model

    • Columns of the foregoing represent all the available columns that can be imported using the import of standard contact feature. The columns do not need to contain information, but they must be present on the page, especially if a column instance contains information.
    • If your organization uses its own unique ID to differentiate customers, then use the ID column of your. If a value is present in this column, it will serve the unique identifier. This means that if the contact has been imported previously, and is to be re-imported then its details are updated, if not a new contact record is created regardless of the fact that contact a similar already exists in the system.
    • If the ID column of your unused, while contacts are usually identified by their email address. The minimum requirement for import a contact into the system that is to be your ID, Email address, full name, first name or last name must be on a single line. If these values are missing the line is not imported and import will move to the next line.
    • If you do not provide your ID or an email address and only a name then the contact is added every time regardless of the question of whether a similar already exists in the system.

    Now my understanding is that if you used the Id of your then being the unique identifier, and that these imports all future would have to use that... Well no, that is not the case at all.

    If you import a recordset using your Id, you can simply update these same records with just the email address - you don't need your Id or external at all!  So, what's the purpose of this field at all? I have no idea myself because he cannot be reported, may not be exported, it cannot be referenced - actually the only way you will see she is to open the CRM folder and view details of Misc and buried at the bottom you'll find. That's what I call a undocumented feature!

    So end of this is - my concerns that whatever proved unfounded and you don't have to worry about external / your field Id, no matter what the customer does.

    My advice - forget this field exists and do not care to use it unless you might happen to be interfacing in some 3rd party system through PAI, as seems to be the only use I can think of for it.

  • Need help with a script (o - o8) *, see the Virgin if there is no

    Hi all what I need help with a script I can't find an example.

    I'm trying to subtract 2 numbers and then multiply this product. (o o8) * one but I just want to do the calculations if all fields have the numbers IE field o, o8 of field and field one.

    Thank you in advance. I was stuck on this days searching the Internet.

    Assuming you want to affect the outcome of this calculation in another text field, use this code as a custom field calculation script:

    var o = this.getField("o").valueAsString;
    var o8 = this.getField("o8").valueAsString;
    var a = this.getField("a").valueAsString;
    if (o!="" && o8!="" && a!="") event.value = (Number(o)-Number(o8))*Number(a);
    else event.value = "";
    
  • [Error number: 0x8024400A] Need help with this error... I reinstalled XP SP1 and I can't get an auto update that's simple to install, just get this error every time

    [Error number: 0x8024400A] Need help with this error... I reinstalled XP SP1 and I can't get an automatic update that's simple to install, just get this error at each time HHHHEEEELLLPPPPP! Thank you

    I had the same problem.  But finally found a solution.  If your listing is similar to mine, then keep.  XP Media Center Edition 2005 (sp2).  AMD Athlon 64 x 2 Dual-Core, HP a1630n desktop computer.

    Go to the HP website, search for sp37394-XP sp3 Upgrade utility Microsoft for systems equipped with AMD processors.

    I had the same 0 x 80240036, 0x8024400a error, but realize my problem was really get manually downloaded sp3 and installed without continue loop crashing and not error messages.

  • Need help with java script

    I have a small script that changes the color of a button image that I use for a popup topic. It does this, of course, by exchanging the two images.

    The script works very well in HR overview and also when the htm page is opened directly in a browser (IE or Chrome).

    However, when I open the topic in the compiled help, the second image does not display.

    Those who work in HR overview. Who isn't in the compiled help.

    Here is the code:

    < a href = "javascript:BSSCPopup('..)". /MenuLocations/3DFace_menu_location.htm'); »

    "ID ="a1"style =" "position: relative;" > < img onmouseover = "this.src = '... /ClickButton - O.png'.

    onmouseout = "" This.src = '... ClickButton.png' ""

    "SRC ="... / clickbutton.png ".

    ALT = "Click for locations of menu and toolbar and related topics."

    border = "0" / >

    Any ideas?

    ~ Margaret Becker

    HI Margaret

    You should probably add the second image to luggage to its intended location. Because JavaScript must manage by exchanging images, RoboHelp is probably not aware of the second image.

    See you soon... Rick

    Useful and practical links

    Wish to RoboHelp form/Bug report form

    Begin to learn RoboHelp HTML 7, 8 or 9 in the day!

    Adobe Certified RoboHelp HTML Training

    SorcerStone blog

    RoboHelp EBooks

  • I got a CD with a file that has the extension .mdb. What are my options to open and view this file? Secondly, the recommendation for pc virus protection?

    I have a HP with Windows Vista Premium installed.  I got a CD with a file that has the extension .mdb.   What are my options to open and view this file?    There is a second file on the disk with an extension .ldb.   What kind of file is it?

    Second, the recommendations that you offer for pc virus protection?   My coverage of Trend Micro systems allows access to the Explorer after I disable add ons... while I am limited with respect to the capabilities of the computer.

    Thank you!

    .Mdb and .ldb file extensions are used by the Microsoft Access database program. .mdb is a .ldb file is a lock file. You may be able to consult the data base with Access runtime, downloadable here:

    http://www.Microsoft.com/downloads/en/details.aspx?FamilyId=d9ae78d9-9DC6-4b38-9fa6-2c745a175aed&displaylang=en

    For an antivirus that doesn't interfere too much, try Microsoft Security Essentials:http://www.microsoft.com/security_essentials/?mkt=en-us . Ensure that anti-virus programs are completely removed, with vendors removal tool, preferably before installation.

  • I don't want to start a discussion! I just want to help with a product that does not work!

    I don't want to start a discussion! I just want to help with a product that does not work!

    http://helpx.Adobe.com/x-productkb/policy-pricing/activation-network-issues.html

    Mylenium

  • Script that returns the name of the user

    Hello, I have a fairly complex script that exports the text of an InCopy document. Is InCopy CS3 and is running on a Windows 2003 platform. It would be useful as this script to find out who is the user, that is who runs the export. Has anyone written a script that removed the username and group ads, the OS, or in fact InCopy. The solution, I think, perhaps by calling an external script that queries the operating system and returns this kind of data. Any thoughts on this topic would be appreciated. Thks, Wil

    On Windows, you can get the name of the user like this:

    Alert ($.getenv ("username"));

    or

    alert ((Folder.temp + "") .slice (12, -14));

    Kasyan

Maybe you are looking for