delete the cell style - to preserve formatting

Hello scripters.

Is it possible to preserve the formatting when I remove a cell applied by the following code style?

"MyCellStyle.remove (app.activeDokument.cellStyles.firstItem ());

How can I access this feature in my script? (see also the screenshot-> red arrow)

perserve_formating.png

Thanks for the tips.

Roland

Roland:
You can browse all your cells with the applied cell style, select the cells, one after the other and apply a menu action to break the link style ("Break link to Style" / "Operation mit Format Hegelian").

You can then delete the cell style without losing any formatting.

To invoke the menu action, you can use this code. For security reasons, I've got it wrapped up with a "try/catch":

//Disconnect the cell with the applied cell style (option in the cell styles panel of the UI: "Break Link to Style" / "Verknüpfung mit Format aufheben"):
try{app.scriptMenuActions.itemByID(132129).invoke()}catch(e){};

Uwe

Tags: InDesign

Similar Questions

  • Delete all character styles and preserve the formatting

    Hi scripters

    I need to remove all the character style using preserve in my document formatting option.

    How can I do this with that I started.

    myDoc = app.activeDocument;

    for (var j = 0; myDoc.characterStyles.length > j; j ++)

    {

    //

    }

    Thanks in advance

    concerning

    a you are the

    During the withdrawal of points, always looping backward (j-) so that your reference is still valid.

  • 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.

  • Help with a script to search for text in a table cell and apply the cell style

    Hello

    I build the script which Jongware wrote in his post here http://indesignsecrets.com/tackling-tables-through-scripting.php - I am trying to create a variable in which I can add a number of different parts of the text, in this case it's different parts of the United Kingdom i.e. 'London', 'East', 'Scotland' etc. I just need the script to apply the cell Style - 'District Cell' - to any cell that contains text in the variable. Here's the script, if anyone can help I would be grateful.

    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!
    
    
    //Find Text in Cell and apply Cell Style
    var textInCell=['London', 'Scotland', 'South West'];
    for (i=0; i<table.cells.length; i++)
    {
    if (table.cells[i].texts[0].contents==textInCell)
    table.cells[i].appliedCellStyle = "District Cell";
    }
    
    
    
    
    }
    

    Hello

    Change this feature:

    function processTable(table)
    {
    //Find Text (exactly as it is) in Cell and apply Cell Style
    var
      textInCell=['London', 'Scotland', 'South West'],
      mFound, cFound;
    
    app.findGrepPreferences = null;
    app.findGrepPreferences.findWhat = "^(" + cities.join("|") + ")$";
    mFound = table.findGrep();
    while( cFound = mFound.pop() )
      cFound.parent.appliedCellStyle = "District Cell";
    }
    

    Jarek

  • Script to apply the cell style after paragraph research

    Hello

    can someone help my make a script to search for all occurrences of a paragraph format in the tables and then apply a cell style to a document the bounding cell.

    Thanks in advance.

    Peter

    BTW Mac InDesign CS 6

    Hello

    Use this:

    var mDoc = app.activeDocument,
    pST = mDoc.paragraphStyles.item("paraStyleName"),
    cST = mDoc.cellStyles.item("cellStyleName"),
    mFound, mParent, count;
    
    app.findTextPreferences = null;
    app.findTextPreferences.appliedParagraphStyle = pST;
    mFound = mDoc.findText();
    count = mFound.length;
    while (count--) {
         mParent = mFound[count].parent;
         if (mParent.constructor.name == "Cell")
              mParent.appliedCellStyle = cST;
         }
    
    app.findTextPreferences = null;
    

    change paraStyleName and cellStyleName

    Jarek

  • The default value of the cell reference to preserve columns and lines in function number 3.6.1

    I use:

    3.6.1 the numbers

    OSX 10.11.1

    For clarity: afterwards, I use the term 'address of the cell' is the name of the Table, the numbers of row and column that is used to specify a particular cell. Please let me know if there is a name for this.

    Am new on numbers and you want to create a database with two tables whose most variables in "Table 2" are determined by entries in 'Table 1' and vice versa. I use the functions to set up these relationships; However, it is not an obvious geographic relationship between the output in table 2 cell address and the address of the entry in table 1 cell, so I want the address of the cell called in any default function to "Preserve line - True" and "Preserve column - True" still, but don't be found anywhere to set this parameter. Is this possible?

    Thank you in advance your help.

    All the best,

    RA

    It is possible that you are trying to do things with numbers for which it is not designed. It's really good at crunching numbers, but this isn't a database program. If you look at the models in file > New in your menu, you will find good examples of use of numbers. To enter formulas usually you don't have to make a lot of seizure of addresses. You type = activate the formula editor, and then click the cell you want to reference. Numbers then inserts the address for you.

    SG

  • Delete the recent pop - up in format Adobe Acrobat, DC

    Hello

    Many users in our environment complains about the pop up recent files every time they are open a new PDF file or just open the program.

    Is there a way to remove this pop?

    / Christian

    Hi Christian,

    Recent file tab is a part of the basic user interface in Adobe Acrobat DC/Adobe Acrobat Reader MS, which cannot be removed or disabled. This function is to provide one-click access to recently used files.

    Let me know if you still have question or you need assistance, we will be happy to help you.

    Kind regards

    Nicos

  • Cell styles missing cell styles in the palette

    Last Friday, I have created a table style and a certain number of cell styles & part of my starting indesign setting initial and included as part of a document and a document template.

    This morning (Monday) when I open Indesign, I noticed my cell styles palette was empty - there is nothing listed here or selectable somehow. Yet the range of styles of table shows the table that I created and when I look at that I noticed that all cell styles, that I created. More later if I try to edit a cell style in the style of table the list and I would select all cell styles that I created last week even though they do not appear in the palette cell styles.

    I tried to delete Indesign Defaults and AppPrefs.xml nothing works. I tried to create new cell styles, but they disappear immediately after creation - the palette remains empty cell styles. I tried to import the model & document styles that I created last week - nothing. I tried to export my model to IDML & reopening; still no go. I checked all paragraph and character styles used by the cell styles and they are present. Nothing seems to work.

    Has anyone else encountered and/or solved this problem?

    Hi again Peter.

    Not sure if it will work or not because I discovered a solution to the problem just before reading your response. When I clicked on the dual turns up and down the arrow on the tab name range to force the palette to expand & contract cell styles suddenly reappeared. As an additional measure, I just went and deleted the file SavedData so just in case where it was corrupted and would create other problems. Problem seems to have been resolved

  • Is it possible to adjust the height of the cell in a cell style?

    In the attached screenshot, the cell height is set to 0.125 exactly. I put my cursor in the cell, and then open the Panel styles of cell and created a new cell style based on the cell. But when I apply the cell style to other cells, it does not live up to cell. There are no substitutions or other styles are applied to other cells. I also opened the cell style definition in the Panel style of cell but don't see anywhere to set the cell height there either. Is there another way to do this that I'm missing?Screen Shot 2012-08-16 at 5.01.57 PM copy.jpg

    It is possible - and it's pretty simple.

    To set the height of row in the cell style, all you have to do is to use the insert of the cell above and below. As long as you set the style as "At least" then it works perfectly well for having predefined cell styles.

    I used it with success of large financial documents for a while without any hitches. For example, I use it to get the separation between the sections of the tables having a style with extra space above, and similarly for the totals at the bottom of the table lines. It can apply of course also different contour styles at the same time. Having the style defined as 'At least' also allows multiple line entries to still have the correct spacing above and below.

    So if you spend a little time of calculation required heights and to set up your styles, then apply a keyboard shortcut to each style, you can then save a lot of time during the formatting of the document.

    I just finished nearly 400 pages of financial tables using this method on the last two days!

    This solution may be suitable for your situation, but if you have a large number of tables to get through, he happened to be useful to give it a try.

  • Tame the table and cell styles

    I find table styles and cell styles to be quite a nightmare in InDesign - in other words, as long as the paragraph style is included in the definition of the cell style. The only way I could get a table without substitution involves the steps as much as it is not effective:

    1) click an empty paragraph.

    (2) apply the paragraph style.

    (3) type the text that will come eventually in a table cell. (All my paintings are a cell, a column tables).

    (4) select the text without selecting the symbol of paragraph at the end.

    (5) choose table > convert text to table.

    I would be very happy if anyone knows of a script that can do these steps and can put me out of my misery.

    (Or maybe is there a way to avoid cell style replacements that I did not discover. (There was a discussion on this problem to http://forums.adobe.com/message/2043634#2043634, but none of the suggestions got rid of substitutions of paragraph style cell.)

    Hi jay

    You should check the character styles. If paragraph styles will not be on the trip, I found that it is because it applies a character style. Some people use styles to the paragraphs format characters. (?!)

    RB

  • The other style of cell lines

    I need to apply the cell style for an alternative line for all tables. But the code below does not correctly how to solve this problem

    var doc = app.activeDocument,

    _tables = doc.stories.everyItem ().tables.everyItem () .getElements ();

    for (var i = 0; i < _tables.length; i ++)

    {

    var _rows is _tables [i] Rows;.

    for (var j = 2; j < _rows.length; j += 2)

    {

    _rows [j].cells.everyItem () .appliedCellStyle = "TableBody1";

    }

    }

    Table.PNG

    Hello

    If code should target a specific range of rows in the table.

    Through the cells in column 1

    ==> from the selected line

    ==> select as many rows as many current . cell rowSpan property says

    ==> apply cellStyle on this range of cells.

    That is like this:

    var
      mDoc = app.activeDocument,
      mTables = mDoc.stories.everyItem().tables.everyItem().getElements(),
      rowsToOmit = 1,     //     how many rows to exclude
      rowIndexToStart = 1,     //     which row is the starting one to apply a style
      mStart, mEnd, step,
      mTables, cTable,
      cCell, cSpan, cRange,
      mCellStyle = mDoc.cellStyles.item("TableBody1");
    
      while ( cTable = mTables.pop() ) {
           mCells = cTable.columns[0].cells.itemByRange(rowsToOmit,-1).cells.everyItem().getElements(),
           for (step = rowIndexToStart; step < mCells.length; step +=2) {
                cCell = mCells[step];
                cSpan = cCell.rowSpan - 1;
                mStart = cCell.parentRow.index;
                mEnd = mStart + cSpan;
                cRange = cTable.rows.itemByRange(mStart,mEnd).cells.everyItem();
                cRange.appliedCellStyle = mCellStyle;
                }
           }
    

    Jarek

  • Apply the table style based on the contents of the cell

    I'm on a Mac, OS 10.8.5 using InDesign 5.

    Does anyone know how to apply a table style based on the content of text found in a cell in javascript?

    I need to find the document and change all the styles table 'LONG orange verbatim' If the text "HS:" appear in the header line.

    I've been playing with scripts found with the following 3 wires, but can get it to apply a table style.

    Thank you!

    Apply Table Cell Style based on text search and How to apply a cell of table based on grep style search? and Re: find PStyle and apply the cell Style in the Table

    Here are the corrected lines:

    var curDoc = app.activeDocument;
    var allTables = curDoc.stories.everyItem().tables.everyItem(); 
    
    app.findTextPreferences = app.changeTextPreferences = null;
    app.findTextPreferences.findWhat = "HS:";
    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;
            if ( curFoundParent.parentRow.rowType == RowTypes.headerRow ) {
                curFoundParent.parent.appliedTableStyle = curDoc.tableStyles.itemByName( "verbatim orange LONG" );
            }
        }
    }
    
  • value of the cell in numbers displays the date instead of the value of the formula in currency

    I use the numbers frequently and a worksheet I'm using suddenly systematically will display a date (April 30, 2017) instead of a sum value that was always there. I tried to change the cell back to currency format, all clear and reset deleting the formal line and inserting a new formula in another cell, and the problem persists. Have left and restarted numbers and the entire computer. Don't know how it happened, or how I can fix this problem.

    Can you post a screenshot?

    SG

  • Right aligned and then centered in the cell of the table - indesign cs 5

    Hi all

    Does anyone know how can I get the numbers right aligned, so the zeros are all below the other. And then the center of the table cell.

    I use a paragraph style is aligned to the right. This is the paragraph defining the cell style.

    Any help would be appreciated.

    Thank you

    Mau

    InDesign CS5

    You can set the position of the tab within the paragraph style, so no, you do not need to edit each cell, but you do not have to use the text aligned to the left, and if you want that all the place line numbers correctly you need to use a font with tabular, rather than numbers proportional to make them all the same width (and for tables rather than oldstyle figures is probably also a better choice).

    When you look at the tabs formatting options that you have left, right, centered and aligned decimals (which can be any character of your choice, but you want the period). When you use the decimal tab aligned, everything you type will behave as if the tab is a tab that is aligned to the right - it will start at the position of the tab and move to the left with each additional character - until you type the character that you chose for the alignment. From there text will move to the right of the alignment. This aims to make things like the columns of numbers with decimals.

    In a table, the tab character is implied, so if the only thing in the cell is your setting of the tab in the style number is sufficient and it will work just as soon as you start typing. If there is other text before alignment numbers that must be the left hard, however, you will need to type, then manually insert a tab in the menu Insert special characters (or create a new shortcut key to insert tabs in tables) to force the text to the left margin and keep the numbers aligned on the decimal point. You can't just hit tab within a cell to add the tab - it reports ID to pass to the next cell.

  • How can I apply a new style with an excerpt and DW artifact of the old style?

    Hello

    I use Dreamweaver CS5 in Windows XP SP3. My problem seems simple, but the resolution remains elusive.

    Let's say I'm stuck-in editing the text in MS Word that DW auto-formaté. I highlight text and use a clip to attach the text of the h2.

    Rather than delete the old style and its replacement by h2, DW applies the h2, but copy the old style, enclosing nothing and it bumps to the next line. If the old style included a paragraph tag, which flows into the extra space. For anything.

    Now, this seems to be a minor thing, but it is not so little, when you try to quickly prepare a large document with different header styles. Having to make dozens of changes that, in my view, should be completely useless becomes a burden.

    Is it possible to attach some text in a new style with an excerpt without the old style of stick around?

    Thanks for all the answers!

    Oreo Say

    If I pointed out this bit and click to apply my excerpt:

    The header

    the result is:

    The header

    You need not of snippets for this.

    Select it

    tag with the selector tag between (bottom of the design view) and the top of the property inspector, then, in the property inspector, Select Heading 2 in the dropdown Format menu.

    DW will replace

    with

Maybe you are looking for

  • NEW optical filter 2K for F55 and F5 CBK-55F2K Option

    All, We will release a new optical filter 2K for the F55 and F5, called the CBK-55F2K Option. The CBK-55F2K translates into 'softer, more organic' imagery when shooting in 4K. When shooting HFR in 2 K RAW the new filter will result in a more pleasant

  • CSV files

    How are Hello everyone, you? I'm working on a software to make measurements using my drone of railroad. My drone generate csv files (such as it is attached). The first column corresponds to the distance that generate the encoder, the second colum is

  • Update wireless card for hp envy 15-1060ea

    Hello I have hp envy 15-1060ea laptop with intel 5100agn wirless card and windows 7 Home premium windows I think to upgrade because I think that my wireless card is not powerful and recovers not signels I saw 2 models that seems better than 5100agn 1

  • Windows 7 and Akai APC40 Plug and Play, no driver not found?

    I just bought an Akai APC40 Ableton Live 8 and every time I plug my apc, it evokes the installation of the device NO DRIVER FIND driver... I thought Windows 7 made controllers like this plug & play compliant? There are no drivers on the Web site to f

  • SanDisk memory card from clipzip

    Inserted in clipzip of Sandisk memory card.  How can I get downloads on this card because my clipzip is full?  Also the map seems stuck in the unit.  Help!