How to apply the character style to table cell

I'm sure it's basic, but I can't find any references on how to do it and my attempts have failed.  I use VB and CS5.5

Basically what I'm trying to do is to select a table cell and apply a character like this style...

MyCharacterStyle = myDocument.CharacterStyles.Add set

myCharacterStyle.Name = "TH2".

myTable2.Cells.Item (1) .appliedCharacterStyle = "TH2".

with this code, I get a "object does not support this property or method.  myTable2.Cells.Item (...). appliedCharacterStyle ".

I tried several other versions without success.

Can someone tell me what would be the proper syntax to apply a character style to text in a table cell, or if it's still the right path to follow on that?

I have to select the text in the cell rather than the cell itself, and if so, how do you do that?

Thank you

You do not need to select the text in the cell, but you need

to target rather than the cell. It is true that in the user interface, you can

Select the cell and apply a style of tank, but not with a script. Thus, in

JavaScript is:

myCell.texts.item (0) = .appliedCharacterStyle

app.activeDocument.characterStyles.itemByName ("MyCharStyleName")

It must be something similar in VB also.

Of course, you can target the text in different ways:

myCell.characters.everyItem () or myCell.paragraphs.everyItem () etc etc.

but I think that the text is the most basic of the lot.

Ariel

Tags: InDesign

Similar Questions

  • How to write the script to apply the character style?

    Hello

    I'm on a Macbook pro and without a numeric keypad, so I can't assign a shortcut to character styles. I heard a roundabout solution where you can assign a shortcut to a script that applies the character styles. Can anyone write this script?

    My character style is called "features"bold. "

    I am new to scripting, sorry if this is a stupid question.

    See you soon

    Hello

    1. save this code as a file inside your Script Panel folder .jsx

    2. apply a shortcut using the menu Edit: shortcuts...

    Option to choose:

    • suggest you choose an option 'background': 'Text', so you can use several shortcuts that are occupied in other contexts.
    #target indesign
    if (app.selection && app.selection[0].hasOwnProperty ("baselineShift") ) {
      var cName = "Features bold";
      var mCstyle = app.activeDocument.characterStyles.item(cName);
      if (mCstyle.isValid)
           app.selection[0].applyCharacterStyle(mCstyle);
      else
           alert ("CharStyle: " + cName + " not found");
      }
    else
      alert ("Some text supposed to be selected...");
    

    Jarek

  • Selection of parts and columns, or entire lines and apply the character style

    I am trying to apply character styles to certain parts/whole rows and columns.

    I can change individual cells with the following code...

    table = app.selection[0];
    if (table.hasOwnProperty("baseline")) table = table.parent;
    if (table instanceof Cell) table = table.parent;
    if (table instanceof Column) table = table.parent;
    if (table instanceof Row) table = table.parent;
    if (table instanceof Table)
    
    {
     table.rows[0].cells[6].texts[0].appliedCharacterStyle = "none report";
     }
    

    ... but when I try to select an entire line, I get the error 'Object does not support property or method' texts. "" "When I try one of the following two codes.

    {
     table.rows[0].cells.texts.appliedCharacterStyle = "none report";
     }
    

    {
     table.rows[0].cells.appliedCharacterStyle = "none report";
     }
    

    Anyone know how I can do the following?

    1. Select any row (or column) and apply the character style

    2. Select the last line (regardless of the number of rows in the table) and apply the character style

    3. apply the character style to specific columns (with theexception of the cells of two albums)

    Thank you!

    Hello

    Change this line:

    table.columns[a].cells.itemByRange(2,-1).texts.everyItem().appliedCharacterStyle = "chart orange";
    

    for the first 2 rows in each column

    Jarek

  • How to apply a character Style that has already been made in a document model?

    First of all, I would like to thank everyone who helps. I am a complete newbie to the script and appreciate your help.

    I mainly use GREP expressions to search for patterns in a document and apply a character Style that has already been done. This character style did not help script, but just in InDesign when the production and implementation of the model.

    var myDoc = app.activeDocument;
    
    
    //Clear the find/change grep preferences.
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    
    //Set the find options.
    app.findChangeGrepOptions.includeFootnotes = false;
    app.findChangeGrepOptions.includeHiddenLayers = false;
    app.findChangeGrepOptions.includeLockedLayersForFind = false;
    app.findChangeGrepOptions.includeLockedStoriesForFind = false;
    app.findChangeGrepOptions.includeMasterPages = false;
    
    //GREP Expression for finding all HEADERS
    app.findGrepPreferences.findWhat = ".+\n";
    
    //Applying formatting changes to put into All Caps, Bold and changing the font size to 12 pt.
    app.changeGrepPreferences.capitalization = Capitalization.allCaps;
    app.changeGrepPreferences.fontStyle = "Bold";
    app.changeGrepPreferences.pointSize = "12";
    myDoc.changeGrep();
    
    //Clear the find/change preferences after the search.
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    

    This is how I currently. I will manually define the changes made to the text. The problem is, each model uses a different set of fonts and not all use them "BOLD", for example Sabon can use THIS "BOLD".

    I would like to know how to apply a character Style and tried to look, but nothing seems to work.

    Any help would be appreciated.

    Thank you.

    app.changeGrepPreferences.appliedCharacterStyle = "A";

  • Apply the character style to the part of the paragraph

    I am inserting text in a block of text with the following code:

    story.insertionPoints [-1] .silence += pgfStr;

    story.insertionPoints [-1] .silence += "\t";

    story.insertionPoints [-1] .silence += refStr;

    story.insertionPoints [-1] .silence += "\r";

    I want to apply the character style to all of the text in refStr (only the part of this paragraph). I know how the syling paragraph applies to the entire paragraph, but not a character style. I should be grateful if you would help. Thank you!

    Hello

    Dan - BTP says:

    ... the size in points and attack can be different on each page...

    You are able to find a rule of these differences?

    ...

    What do depends on what type of rule could be defined

    ...

    The size of reference point that is 1.5 PT lower than the point size of the paragraph, whatever.

    Close to the end of the script, you can code for example:

         //     Your target is "reference" which is a text inbetween tabulator and end of story (or other criteria).
         //     So you could define:
    app.findGrepPreferences = null;      // just for clear it
    app.findGrepPreferences.findWhat = "(?<=\\t).+\\s\\Z";     //     to catch text following tab in last para of story
         //     and after:
    mFound = app.activeDocument.findGrep();
         //     so all desired text objects are in an array "mFound".
         //     you could iterate (backward) through it:
    len = mFound.length;
    while (len-->0)      //     ">0" in case of nothing found
         mFound[len].pointSize -= 1.5;
    
         //     whatever that is - is 1.5 smaller
    

    Jarek

  • Table of contents, problems in applying the character style

    Hi all

    This is my first post, I checked if there was already something similar, but I can't find anything so I'm asking here.

    I work with Indesign 9.3 and I created a book of 80 pages and there are 20 + chapters.

    I wanted to create a table of contents, so I made an and I put my paragraph for her style, but I had problems to set the character style (he set only to the number of the page, but not to the number and the name of the chapter).

    When I create my summary style I have no problem to indicate the paragraph style that you want to use (and then it automatically applies it properly when I generate my list).

    The problem I want to solve, is that I need that my table of contents automatically the value of the character style, cause, for the moment, I have to apply it after its generation.

    Sorry for my bad English, I hope you understood

    Concerning

    Filippo

    In this case you must use the character for numers style nested within the paragraph style

    I'm usually two independent sparagraph styles (primary materials) chapters and sections (toc details). In this way, you can add a different same nested character style to stand them.

    Addibn later - style, it is not good idea. After the update of the table of contents, you have lost the

    macpawel

  • How to use GREP to apply the character style just for the first and the second line of the paragraph?

    as the title, I just want to ask how to apply the style of character just for the 1st and 2nd line of the paragraph. Help me pls, tks!

    Can you show the screen shot with the invisible market, looks like you feedback after each line.

    So, something like this would work where I have a return forced for the linebreak (shift + return). The example on the right does not work because the line break is a return:

  • Is it possible to add text to the cells and apply the character style in the cell

    I work in InDesign on Mac 5.

    I have two tables of formatting with information that will be eventually combined. I implemented the scripts I found on these forums to add the columns needed, merge lines and fill the cells merged with the appropriate color, but can't two remaining tasks.

    1. is it possible to add text to a cell of some?

    2 and it is possible to apply a character style to cells? (different cells than those that I need to add some text)

    I played with this code but do not know if it is even close...

    {

    table. Rows [0]. Cells [0]. InsertText (' CS/PS");

    }

    {

    table. Rows [0]. Cells [0] .appliedCharacterStyle ("bold");

    }

    Here are the scripts that I have combined so far for the table...

    Add column

    myTable = app.selection [0];

    MyColumn = myTable.columns [1];

    for (a = 0; < 1; a ++)

    {

    myTable.columns.add (LocationOptions.AFTER, myColumn);

    }

    Merge lines

    table = app.selection [0];

    If (table.hasOwnProperty ("baseline") table) = table.parent;

    If (instanceof cell table) table = table.parent;

    If (instanceof column table) table = table.parent;

    If (instanceof row table) table = table.parent;

    If (instanceof Table table)

    {

    table. Rows [0]. Cells [0]. Merge (table.rows [0] .cells [1]);

    }

    {

    colours alternating in merged lines

    r = table.rows [1];

    n = app.activeDocument.swatches.item ("orange");

    b = app.activeDocument.swatches.item ("PANTONE 3005 C");

    for (c = 0; c < r.cells.length; c ++)

    {

    If (c & 1)

    r.Cells [c]. Properties = {fillColor:b};

    on the other

    r.Cells [c]. FillColor = n;

    }

    }

    Hello

    1. If you want to add the text, go further in:

    table. Rows [0]. Cells [0] .insertionPoints [0] .silence = ' CS/PS;

    2 similar with application of styles:

    table. Rows [0]. Cells [0] .texts [0] .appliedCharacterStyle = "bold" / / If this style is present in your doc

    Jarek

  • [JS] [CS3] Apply the character Style to the first word

    I'm a noob that Javascript is concerned, and I expected a little guidance.

    Here is my scenario: I have a book that was composed in a single file; the main content is in a story. I want to select the first word in each block of text on each page and apply a character style. My goal is to use this character style to indicate the page breaks in the XML document - I maps to a specific tag style.

    So far, I have this poor specimen:

    myDocument var = app.activeDocument;
    myPage var = myDocument.pages.item (1);
    var myTextFrame = myPage.textFrames.item (0);


    If (app.activeDocument.stories [0] .paragraphs [0] .words [0]! = null)
    myTextFrame.paragraphs.item (0).words.item (0) = .appliedCharacterStyle
    myDocument.characterStyles.item ('foo');

    I know, I did not implement any kind of loop again (which will be more complicated given that there will be some blank backs, etc.). What I try to do in this is to select the first word in the first paragraph on the second page - which it does in reality. It's the first paragraph of the second begins on the first page, so I select that word on the first page, second page.

    As I said, a lot of work to do but a bit of help on getting to the right word would be most appreciated.

    Well, you were on the right track, but the "myText" test fails if there is no block of text on a page, because it fails a line earlier

    > var myTextFrame = myPage.textFrames.item (0);

    just before that, you must test the number of blocks of text:

    If (myPage.textFrames.length > 0)

    {

    ... your stuff...

    }

    Use it only if you are absolutely positive that there is just a block of text on each page! A slightly better way would be to always loop on each textframe:

    for (frames = 0; frames

    {

    var myTextFrame = myPage.textFrames.item (frames);

    .. etc.
    }

    in this case you don't have test his first length (the loop will not be executed if there is zero text blocks).

    [Grumpy] Since you have only a continuous story, an even better way would be to loop on texts related to this single story executives. You must identify the story somehow, and I usually click on the text cursor in the one that I need:

    monarticle = app.selection [0] .parentStory;

    or you can rely on the fact that the story begins as part of text on page 1:

    monarticle = app.activeDocument.pages [0] .stories [0];

    (I think this should work.) Then, each frame of the story until the end can be found in the table

    myStory.textContainers

    which are usually text blocks. Make a loop on them to help

    for (image = 0; frame)

    {

    myTextFrame = myStory.textContainers [frame];

    .. etc.

    }

  • Apply the character Style to a few characters in a paragraph

    Hey,.

    Me again - I feel like I'm dumber than a shoe trying to script InDesign

    I have a block of text with several paragraphs, which I am adding one by one.

    When adding these paragraphs, sometimes I need to apply a character style to some of the characters in the paragraph (I have the clues start and end of these characters to the text of the paragraph).

    Using the Guide of the script and the object reference, I cooked up this code below, but not only it doesn't seem to find the character style, she also told me the. itemByRange() is not a function...

    What's wrong?

    var line_styles = [{
        'start': 22,
        'end': 33,
        'style': 'Price - SKU'
    }];
    
    frame.contents += "\r" + line_text;
    frame.parentStory.paragraphs[-1].applyParagraphStyle(style);
    
    for ( var j = 0, k = line_styles.length; j < k; j++ ) {
        var char_style = doc.characterStyles.item(line_styles[j].style);
        frame.parentStory.paragraphs[-1].itemByRange(
            line_styles[j].start,
            line_styles[j].end
        ).applyCharacterStyle(char_style, true);
    }
    

    frame.parentStory.paragraphs[-1].itemByRange(...

    does not compute. "paragraphs [-1]" points to a single paragraph and is not an itemByRange method. You must think of sth like

    frame.parentStory.paragraphs[-1].characters.itemByRange(...

    (Have you used another programming language Javascript front?) A matter of concern for the future: pay attention to your statements 'var '. They do not follow the block scope, as they do in other languages, and therefore persisted in this notation is very likely to bite you back somewhere in the future. Summer, done this, released as well the hair).

  • How to apply the created style as a number of list twice but the new paragraph begins number 1?

    Hi all

    I work in design and I created a style sheet that applies the list of numbers in the paragraph highlighted.

    NOOW I am facing a problem. If the same style on the same page but for another paragraph he continues with the next number in the first list of numbers, as it actually should start with number 1.

    Does anyone know how to start the next list of numbers with number 1 again even if I apply the same style of number again to a different point on the same page?

    Please let me know.

    Thanks in advance for your help.

    Quick fix:

    Right-click / CTRL-click (to get the context menu) on the first line of the second number list and select Restart numbering from the list of options.

    Repeat as needed for the following lists.

  • How to apply a character style to url an email?

    Mac-Indesign CC

    I am trying too use a grep style to apply a character style to url an email?

    Is this possible?

    Better to consider Nina Storm

    Hello

    Try this:

    [^\s]+@[^\s]+

  • Grep help to apply the character style

    I could use help to refine the expression grep ((Figure|)) Table | Graph)\s\d+\.\d+) below to include Figure | Table | Graphic that have a two digits after the decimal point.

    for example below works on "Figure 1.9" but not for 'Figure 1.10 '.

    In addition, the expressions shown in the image below could be written to include the pural of each word, if there is a reference to a series? the list below

    • Figure 1.9 and 1.10
    • Tables 2.3 to 2.7
    • Chart 3.4, 3.6 - 3.8 and 3.11

    grep help.jpg

    OK, the forum has excluded the \s in the expressionand put in a space.

    (Figure |) Table | Graph)s*\s\d+\.\d+ will find as well singular and the plural of all three options.

  • apply the character style to all get a table row?

    Hi chaps (and chapettes)

    I have a table - on some lines, I need to change the style of character to "Bold".

    How should we do about it in Javascript?

    see you soon

    Buzz

    Have you thought about this?

    myRow.cells.everyItem () .texts [0] .appliedCharacterStyle = myChstyle;

    Does it work? The difference between this one and your function is that you avoid using the style of the empty cells c., which is not possible with the one-liner above.

    Peter

  • How to apply the paragraph style to all paragraphs

    Hi people,

    Simple question. New to JS script here (but so far love it).

    I am trying to apply a paragraph (myTextStyle) style to all paragraphs in a story.

    Right now, I set it up as follows:

    tabletDocument.pages.item (0).textFrames.item ("story").paragraphs.item (0) .applyParagraphSty (myTextStyle, true);

    Obviously, it's just the first paragraph - item (0)-, but no changes to the code it throws.

    Can I implement something to it or a beach (first to last), so it will apply to all of them?

    Thanks in advance!

    N

    Just set the property .appliedParagraphStyle on the whole story.

Maybe you are looking for

  • Mac Mini replacement screws?

    I have a Mini Mac for end-2012 which is in pieces and eventually acquired all the parts to put it back together. However, it is missing a few screws (of different sizes), and I can't find anywhere online that has those that I need. Having never rebui

  • I can not use iPhone 6s hotspot

    I can't use iPhone 6s via hotspot to access the internet I already install iTunes and my iTunes and the iPhone are the version lasted, but when I connect iPhone via wifi without success to connect or I try to connect via buletoot USB or failure, he c

  • LaserJet MFP127fn fax sending question

    I'm having a problem with several units of Laserjet MFP127fn that comes to buy. When I go on send a fax and start typing the fax in the unit number, he's trying to connect before, I finished dialing the number. Other times he said cancelled fax but i

  • This app is not eligible for promotions

    I see the following error message for any application that I'm trying to create a promo code:-This application is not eligible for promotions Including applications, I have codes for. It seems not to work for any of my applications. Ideas on how to s

  • Setting up email for blackBerry Smartphones, missing from section

    Hello I have a v5.0.0.423 bold 9700 It is on o2 uk, now I asked about blackberry bolt, this must be activated on Monday, but don't know if its me but when entering the email set up wizard I only get the blackberry Enterprise installation and not one