Scripts to clear style overrides

I want to create a script in InDesign that clears my replacements on a specific paragraph style. Any ideas?

Hi mikej3204

I've set up a few lines.

Try them and see if they work for you.

Kind regards

Daniel (from Switzerland)

main();
exit();

// needs some refinement to fit your needs
function main() {

//    try it with both functions
//    doitWithSelection();
    doitWithAllParagraphs();

    alert("Information\nI've done my job, what about yours");
}

// 1. Select a paragraph (click 4 times into text)
// .2 start the program
function doitWithSelection() {
    var myDoc = app.activeDocument;
    if (myDoc != null) {
        var myParaSel = myDoc.selection[0];
        if (myParaSel.constructor.name == "Paragraph") {
            // you have to change the "Test" with your paragraphstyle where you want to clear all overrides
            if (myParaSel.appliedParagraphStyle == myDoc.paragraphStyles.item("Test") ) {
                myParaSel.clearOverrides();
            }
        }
        else {
            alert("Information\nNo paragraph selected");
        }
    }
}

function doitWithAllParagraphs() {
    var myDoc = app.activeDocument;
    if (myDoc != null) {
        var paras = myDoc.stories.everyItem().paragraphs.everyItem().getElements();
        for (var i = 0; i < paras.length; i++) {
            myParaSel = paras[i];

            // you have to change the "Test" with your paragraphstyle where you want to clear all overrides
            if (myParaSel.appliedParagraphStyle == myDoc.paragraphStyles.item("Test") ) {
                myParaSel.clearOverrides();
            }

        }   // for the for loop
    }
}

Tags: InDesign

Similar Questions

  • [CS3] Cell [JS] clear style overrides

    Hello

    I need help how to use the clear cell style overrides option when you apply a style to the cells. I used the following statement to apply the cell style

    myTable.rows.item (0).cells.everyItem () .appliedCellStyle = 'theader '; I don't know what is the method (syntax) to use clear override option.

    Concerning

    Kumar

    void clearCellStyleOverrides ([clearingOverridesThroughRootCellStyle:bool = false])
    Clear cell Style overrides

    clearingOverridesThroughRootCellStyle bool If true, clears all replacements, if they are defined in the style of the underlying cell (optional) (default: false)
  • keep stories on master page in clear style overrides...

    Hello world

    I find the stories in the paper and apply clear style via javascript overrides. When I do cela my history of page master are also get affected. Y at - it an option or a way to skip those stories of master page?

    Please suggest and help out me.

    Thanks in advance

    Indana

    Hi John,.

    monarticle [j].parent.parent is the parent of the parent of a story.

    The parent of a story is a document.

    The parent of a document is the application.

    Then monarticle [j].parent.parent meets the demand and will never be an instance of spread or MasterSpread.

    The story itself is not an element of a spread or MasterSpread, but it is textContainers are.

    You need to check if the textContainers of a story are the elements of a MasterSpread instead.

    For a history cannot flow to a textframe to a MasterSpread in a bound of spread (vice versa) textFrame each textContainers a story will be the elements of a spread or a MasterSpread. So you no longer have check if the first textContainer of a story is an element of a spread or an element of a MasterSpread (possible others would also be elements of this or that).

    Then try this (in CS3/4):

    var myStory = app.activeDocument.stories;
    for (var j = myStory.length - 1; j >= 0; j--)
    {
         if(myStory[j].textContainers[0].parent.parent instanceof Spread)
             myStory[j].clearOverrides();
    }
    alert ("DONE");
    

    Martin

  • MaxL Script to clear the data between two dates

    Hi all

    I need advice to clear the data between two dates, I have three dimensions in my sketch, 'eno', 'hiredate' and the 'actualamount '.

    Now I need to erase the data between the date range, up to now, I have this script,

    Fix ("HireDate", "Eno")

    Difficulty (@relative ("00:00:00",0),@relative("eno",0)) 2015-07-15 "))

    CLEARDATA "sal."

    endfix

    ENDFIX

    These scripts only clears on a specific day, but I tried to write the script to clear between two dates, I surfed on a few sites, but no clear answers, finaanly came here, kindly help in this regard.

    Thanks in advance.

    Have you not tried the format of "startdate":"enddate" for example "August":"September."

    See you soon

    John

  • Point to add to the script or Grep Style?

    Hello

    Is it possible to add a hightlight to a script?  Basically, what I want to do is highlight the text and the tricky part is that the text changes size depending on the size of the file, we are working on that.  I want to highlight automatically the "FOR PROFESSIONAL USE ONLY" the way that we do now is to underscore that in the menu options underscore: say my font size is 8, leading 9.6 (these will always change).

    Weight: = 9.6

    Shift: = - 8*.33

    Color = yellow

    It's the way we do now.  Can it be scripted or Grep style which will automatically do this for certain lines of text only?  And no matter the font size calculate what he needs to do if its 2pt, 10pt 100 PT etc... It will highlight the text specified correctly?

    I hope it's possible...

    Thank you

    The lower one is best.

    I remove a bug and also if not 'what' is provided to the point function culminating and there is no entry in find it which is the find panel of text and text is selected, then this text is highlighted.

    An idea in the script is that a shortcut can be applied to it and it will get its information from the Panel of text search.

    So for now to change the answer to this one

    // Highlight function by Trevor
    // http://creative-scripts.com
    // Custom Scripts for Adobe InDesign, Illustrator and a lot more
    // Beta Version 1
    // https://forums.adobe.com/message/8898663#8898663
    
    function highlight(what, color) {
        var range, s, doc;
        doc = app.properties.activeDocument;
        if (!doc) {
            return 'No Active Document';
        }
        s = app.selection && app.selection[0];
        range = (s && s.properties.underline !== undefined && s.characters.length) ? s : doc;
        app.doScript(f, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Highlight Text');
    
        function f() {
            var finds, find, l, leading, pointSize, currentChangeProps;
            color = color || app.activeDocument.colors.itemByName('Yellow');
            // Store current find change text settings
            currentFindTextWhat = app.findTextPreferences.findWhat;
            currentChangeProps = app.changeTextPreferences.properties;
            what = what || currentFindTextWhat;
            if (what !== '') {
                // if no what is provided then the current entry in the find text panel will be used
                app.findTextPreferences.findWhat = what;
                app.changeTextPreferences.changeTo = '';
                app.changeTextPreferences.underline = true;
                app.changeTextPreferences.underlineColor = color;
                finds = range.findText();
                range.changeText();
                l = finds.length;
                while (l--) {
                    find = finds[l];
                    leading = find.leading;
                    pointSize = find.pointSize;
                    leading = pointSize * find.autoLeading / 100;
                    find.underlineWeight = leading + 'pt'; // This is presuming that font and leading size is set to points!
                    find.underlineOffset = (pointSize - leading) * 1.5; // The 1.5 might need tweaking but seems to work well
                }
                app.findTextPreferences.findWhat = currentFindTextWhat;
                app.changeTextPreferences.properties = currentChangeProps;
            } else if (range !== app.activeDocument) {
                leading = range.leading;
                pointSize = range.pointSize;
                leading = pointSize * range.autoLeading / 100;
                range.underline = true;
                range.underlineColor = color;
                range.underlineWeight = leading + 'pt'; // This is presuming that font and leading size is set to points!
                range.underlineOffset = (pointSize - leading) * 1.5; // The 1.5 might need tweaking but seems to work well
            }
        }
    }
    
    /***************************************************************************************************************************************
    ** If text is selected then the "highlighting" is only applied within the selected text                                              **
    ** Otherwise the "highlighting" is applied within the whole document                                                                **
    ** One could change this to apply to what ever is selected in the Find text document if one wanted to                                **
    ** To highlight the word(s) in the find text panel just use highlight(); or highlight(undefined, app.activeDocument.swatches[5]);    **
    ** One can use highlight('Foo'); to highlight "foo" and ignore what's in the find text panel                                        **
    ** The formating / styles etc. for the find are taken from the find panel                                                            **
    ** If one provides a swatch as the second argument highlight(undefined, app.activeDocument.swatches[5]); that swatch will be used    **
    ** otherwise yellow will be used                                                                                                    **
    ** If one provides a swatch as the second argument highlight(undefined, app.activeDocument.swatches[5]); that swatch will be used    **
    ** If text is selected and what argument is given and the find what in the find panel is empty then the selected text is highlighted **
    **************************************************************************************************************************************/
    
    highlight();
    
  • Can I clear throughout this paragraph style overrides the time?

    Sometimes when I change a paragraph style, the places where I applied it compliance. Why is this?

    I end up having to go through the entire document and pressing "Delete replacements." Is there an easier way?

    Thank you!

    Put in local form always trumps style.

    Try using find/replace, however, search for the style and replace it with the same style. Who could do.

  • Compensation style overrides for all paragraphs

    Hi all

    I want to erase the overrides of style for all paragraphs.

    How this javascript?

    Thanks in advance.

    Kind regards
    Sam

    Hi Sam,

    Use of the underside of coding to clear all the substitutions:

    myDocument var = app.activeDocument;
    for (var i = 0; i)<=myDocument.stories.length;>
    {
    myDocument.stories [i] .clearOverrides ();
    }

    Alert ("overrides Cleared...");

    I hope this will solve your problem.

    Kind regards
    River. P

  • Bike via script of paragraph styles - need help

    Hello

    I have a large document (potentially 3000 pages), on each page is a picture of a picture frame and inside each image is a famous quote. I need to type in each quote so I have 10 configuration value different paragraph styles in a different font. I need a script that applies "QuoteStyle1" the text on the first page, "QuoteStyle2" on the next page, etc., and once that 'QuoteStyle10' has been applied the script performs a loop and continues to scroll through the styles apply a style that is different on each page, until it reaches the end of the document.

    I got a start on the script (see image), but I think the problem is the line 11 - I want to run the script without having to select anything.

    Some additional info that may or may not be of use - all quotes are drawn from a data merge. There is also a name and a color from the data merge. The background on each frame is a different color and that is created with the a very large 'rule below' in a number of other paragraph styles. They are applied with a 'Find & ReplacebyList' i.e. find replace 'Red' with the paragraph style "ColourRed. In the script, I tried to ignore these "color" paragraph styles (lines 2-9) is only the 'quote' styles that the effects of the script.

    Any help getting this race would be more useful.Screen Shot 2015-07-15 at 10.01.20.png

    First of all congratulations for the very creative use of blending modes. I would have never thought about it by myself.

    Now, for the script, here are two ways to do it (both enjoy the fact that you use a paragraph style BaseQuote):

    (1) use a grep search:

    var doc=app.activeDocument;
    var baseQ=doc.paragraphStyles.item('BaseQuoteStyle');
    var switchToStyles=[
    'QuoteStyle1',
    'QuoteStyle2',
    'QuoteStyle3',
    'QuoteStyle4',
    'QuoteStyle5',
    'QuoteStyle6',
    'QuoteStyle7',
    'QuoteStyle8',
    'QuoteStyle9',
    'QuoteStyle10'];
    var l=switchToStyles.length;
    app.findGrepPreferences=app.findChangeGrepOptions=null;
    app.findGrepPreferences.appliedParagraphStyle=baseQ;
    app.findChangeGrepOptions.includeMasterPages=false;
    var quotes=doc.findGrep();
    for (var i=0; i
    

    (2) scroll all managers of related texts:

    var doc=app.activeDocument;
    var baseQ=doc.paragraphStyles.item('BaseQuoteStyle');
    var pags=doc.pages.everyItem().getElements();
    var switchToStyles=[
    'QuoteStyle1',
    'QuoteStyle2',
    'QuoteStyle3',
    'QuoteStyle4',
    'QuoteStyle5',
    'QuoteStyle6',
    'QuoteStyle7',
    'QuoteStyle8',
    'QuoteStyle9',
    'QuoteStyle10'];
    var l=switchToStyles.length;
    for (var p=0;p		   
  • Script of paragraph style

    Hi all

    I use InDesign for a newspaper until it goes to press. I created all the necessary paragraph styles, however they are not available on every new page, so I have to manually load them from a template. We are part of a chain of newspapers and do not receive our internal models, so it is difficult to have the styles incorporated into models, created from the master page to the company. It would be wise for companies to provide the same styles to all their papers, but I guess it would make too much sense.

    Is there a way to create a script or another method be more easily able to load styles of paragraph for each page of the log. Some of my colleagues were really struggling with that and so that they use the wrong fonts, sizes etc. which is a real problem come press time. Thanks in advance.

    Brandon

    Seems to me that it is a reasonable request to have a script, preferably that is triggered by the command file open, that could automate load styles to a reference document if there is no way to get the model fitted with the correct styles upstream. Is this the best solution? No, but it would save time and ensure that the styles are always loaded and always loaded from the same source, reducing errors.

  • RMAN SCRIPT TO CLEAR THE BACKUP ITEMS MORE THAN 2 DAYS...

    Hello

    I take a full backup of the DB using RMAN script. The script is as below:

    grc_backup
    {allocate channel ch1 type disc format ' / home/oragrc/GRCbkup/rman_bkp/data/%T_%c_%s_%f';}
    backup database;
    SQL ' ALTER SYSTEM
    ARCHIVE LOG CURRENT ';
    change archivelog than any overlap;
    ARCHIVELOG backup all the format ' / home/oragrc/GRCbkup/rman_bkp/Archive/%T_al_%U.bck';
    current backup controlfile as ' / home/oragrc/GRCbkup/rman_bkp/%T_cf_%U.bck';
    }


    This script is supposed to run on a daily basis via an OS script.

    The problem is on a daily basis after the backup that I have to delete the backups more than 2 days. For this I use an OS script that finds the backups more than 2 days to find the command and deletes it. This script also removes the archivelogs over 2 days.

    I just know that it is not advisable to delete RMAN backups and archived logs OS command when using RMAN.

    I figured out the following script, I have changed the script and instance names are different please find below

    CONFIGURE REDUNDANCY 2 RETENTION STRATEGY;
    Configure type disk parallelism 1 backup compressed backupset device type;

    run
    {
    allocate channel d1 type disk;
    backup filesperset 5 ' format / u06/backup/EBSDEV/EBSDEV_data_t%t_s%s_p%p' database;
    SQL 'alter system archive log current';
    format of backup filesperset 20 ' / u06/backup/EBSDV3/EBSDV3_arch_t%t_s%s_p%p' all entered archivelog delete;
    backup format ' / u06/backup/EBSDEV/EBSDEV_control%U' current controlfile;
    backup spfile format ' / u06/backup/EBSDEV/EBSDEV_spfile_%U';
    SQL 'alter controlfile backup trace database as "/tmp/control.trc" re-use";

    OVERLAP BACKUPSET;
    DELETE NOPROMPT OBSOLETE;
    DELETE THE EXPIRED NOPROMPT BACKUP;
    }
    list summary backupset;
    "exit";

    Can someone suggest me this AM I correct...

    Yes.

    Note: The OVERLAP should be OVERLAPPING BACKUP.

    Hemant K Collette

  • After the creation of these character styles, apply clear replacements...

    Hello world

    After you import the Word document into InDesign CS3 in some paragraphs, there are some substitutions of style. InDesign formatting styles are not correctly designed with paragraphs. Even if that word styles are mapped with InDesign styles exactly. If I select all paragrahs and click on the 'Clear the replacements' option in the palette paragraph styles, all InDesign formatting styles are applied correctly, but the character style formatting are removed. So I planned to create the script for each font style character style and each formatting characters. After doing this I can clear overrides paragraph hassle styles. I have created the script to create styles for characters and formatting his job very well, but when I tried to run this script for the 2nd time in the same document that it showing an error inside. Please find below my script and it is too large,

    ------------------------------------------------------------------------------------------ -------------------

    To find the police and setting styles in form and its replacement by styles of characters
    Script for CS3

    inDesign #target
    myDoc var = app.activeDocument;
    If (myDoc.characterStyles.item ("Itl") == null) {}
    var Itl = myDoc.characterStyles.add ({name: "Itl", fontStyle: "Italic"}) ;}
    If (myDoc.characterStyles.item ("bl") == null) {}
    BL var = myDoc.characterStyles.add ({name: "bl", fontStyle: "Bold"}) ;}
    If (myDoc.characterStyles.item ("bItl") == null) {}
    bItl var = myDoc.characterStyles.add ({name: "bItl", fontStyle: "BoldItalic"}) ;}
    If (myDoc.characterStyles.item ("bItal") == null) {}
    Bollet var = myDoc.characterStyles.add ({name: "bItal" fontStyle: "Bold Italic"}) ;}
    If (myDoc.characterStyles.item ("sb") == null) {}
    SB var = myDoc.characterStyles.add ({name: "sb", fontStyle: "Semibold"}) ;}
    If (myDoc.characterStyles.item ("sbItal") == null) {}
    var sbItal = myDoc.characterStyles.add ({name: "sbItal", fontStyle: "Semibold Italic"}) ;}
    If (myDoc.characterStyles.item ("blk") == null) {}
    BLK var = myDoc.characterStyles.add ({name: "blk", fontStyle: "Black"}) ;}
    If (myDoc.characterStyles.item ("obl") == null) {}
    OBL var = myDoc.characterStyles.add ({name: 'obl', fontStyle: "Oblique"}) ;}
    If (myDoc.characterStyles.item ("li") == null) {}
    Li var = myDoc.characterStyles.add ({name: "li", fontStyle: "Light"}) ;}
    If (myDoc.characterStyles.item ("liItal") == null) {}
    var liItal = myDoc.characterStyles.add ({name: "liItal", fontStyle: "Light Italic"}) ;}
    If (myDoc.characterStyles.item ("sup") == null) {}
    var sub = myDoc.characterStyles.add ({name: "sup", position: Position.superscript}) ;}
    If (myDoc.characterStyles.item ("sub") == null) {}
    void var = myDoc.characterStyles.add ({name: "sub", position: Position.subscript}) ;}

    app.findTextPreferences = NothingEnum.nothing;
    app.changeTextPreferences = NothingEnum.nothing;

    app.findTextPreferences = null;
    app.changeTextPreferences = null;

    app.findTextPreferences.fontStyle = "italic";
    app.changeTextPreferences.appliedCharacterStyle = Itl;
    App.Documents.Item (0) .changeText ();
    app.findTextPreferences.fontStyle = "Bold";
    app.changeTextPreferences.appliedCharacterStyle = bl;
    App.Documents.Item (0) .changeText ();
    app.findTextPreferences.fontStyle = "BoldItalic";
    app.changeTextPreferences.appliedCharacterStyle = bItl;
    App.Documents.Item (0) .changeText ();
    app.findTextPreferences.fontStyle = "Bold Italic";
    bItal = app.changeTextPreferences.appliedCharacterStyle;
    App.Documents.Item (0) .changeText ();
    app.findTextPreferences.fontStyle = "Semibold";
    app.changeTextPreferences.appliedCharacterStyle = sb;
    App.Documents.Item (0) .changeText ();
    app.findTextPreferences.fontStyle = "Semibold Italic";
    app.changeTextPreferences.appliedCharacterStyle = sbItal;
    App.Documents.Item (0) .changeText ();
    app.findTextPreferences.fontStyle = 'Black ';
    app.changeTextPreferences.appliedCharacterStyle = blk;
    App.Documents.Item (0) .changeText ();
    app.findTextPreferences.fontStyle = "Oblique";
    app.changeTextPreferences.appliedCharacterStyle = obl;
    App.Documents.Item (0) .changeText ();
    App.Documents.Item (0) .changeText ();
    app.findTextPreferences.fontStyle = "light";
    app.changeTextPreferences.appliedCharacterStyle = li;
    App.Documents.Item (0) .changeText ();
    app.findTextPreferences.fontStyle = "Light Italic";
    app.changeTextPreferences.appliedCharacterStyle = liItal;

    app.findTextPreferences = NothingEnum.nothing;
    app.changeTextPreferences = NothingEnum.nothing;

    app.findTextPreferences.position = Position.superscript;
    app.changeTextPreferences.appliedCharacterStyle = sup;
    App.Documents.Item (0) .changeText ();
    app.findTextPreferences.position = Position.subscript;
    app.changeTextPreferences.appliedCharacterStyle = sub;
    App.Documents.Item (0) .changeText ();

    function setupFindText (find, change, PT, hidLayers, lockedLayers, lockedStories, masters caseSensitive) {}
    app.findTextPreferences = null;
    app.changeTextPreferences = null;
    try {app.findTextPreferences.findWhat = find} catch (e) {};
    try {app.changeTextPreferences.changeTo = change} catch (e) {};
    app.findChangeTextOptions.properties = {}
    includeFootnotes: (PT == null? false: PT).
    includeHiddenLayers: (hidLayers == null? false: hidLayers).
    includeLockedLayersForFind: (lockedLayers == null? false: lockedLayers).
    includeLockedStoriesForFind: (lockedStories == null? false: lockedStories).
    includeMasterPages: (masters == null? false: Masters).
    includeCaseSensitive: (caseSensitive == null? false: caseSensitive)
    }
    } / / end setupFindText
    Alert ("DONE");

    ------------------------------------------------------------------------------------------ -------------------

    Please suggest how simply this script and make it run faster that anyone can suggest me. Also suggest me how can add this "Clear Override" syntax with this script. I want to make this very effective script. Thanks in advance to all.

    Concerning

    Indana

    Enough basic syntax, really.

    First, as indicated in the documentation, the argument is optional; Second, its default behavior is "All". You get 'all', because you have not provided any argument, and you expected something else. Apparently, you want to clear the formatting only. Just use

    myStory[j].clearOverrides(OverrideType.PARAGRAPH_ONLY);
    

    Notice that the documentation indicates the return type of this function is zero; This means that you get no return value, and it is of no use to "store" the result in a variable myOvClr.

  • Overrides of style when you place in CS4

    I get author-'style' of documents created in MS Word. I go through these documents removing styles applied to the author and replacing them with styles that are correlated with the styles that I use in ID CS4. I then use the location to place the re-designed document in ID. I go through the first mapping type. The problem is that, sometimes, the ID style is changed to placing it, for example a font being substituted. You will see the symbol next to the name of the style in the appropriate panel.

    My question is this: is there a way to prevent that from happening or, Alternatively, to remove all overrides of the document at the same time?

    Thank you.

    West a nice article on this ID to:

    http://InDesignSecrets.com/clear-text-overrides-from-Word-files.php

    And the comments are worth reading too...

  • Why most of my files suddenly converted to cascading and JScript Script Style files? Please, help if someone knows why!

    I installed translation software called SDL Trados 2011 SP2 with all its components, and that's when I noticed that a lot of my files (document libraries) have been converted into file formats of JScript Script and Cascading Style files. I had uninstalled the SDL and all its components, but the files in my documents are always messed up. Maybe, my installation of software has nothing to do with the format changed and something else made?

    Thank you in advance for your help!

    Hello

    Thanks for posting your query in the Microsoft Community Forums.

    After the description of the question, I understand that most of the files is converted to a JScript Script and files in Style files in cascade on the Windows 7 computer.

    I understand this must be frustrating, but don't worry, we're here to help and guide you in the right direction.

    I suggest you to refer to the help article and check if it helps.

    When you run an .exe on a Windows XP, Windows Vista or Windows 7 computer file, the file can start another program

    http://support.Microsoft.com/kb/950505

    Note: This section, method, or task contains steps that tell you how to modify the registry. However, serious problems can occur if you modify the registry incorrectly. Therefore, make sure that you proceed with caution. For added protection, back up the registry before you edit it. Then you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click on the number below to view the article in the Microsoft Knowledge Base. How to back up and restore the registry in Windows:
    http://Windows.Microsoft.com/en-us/Windows7/back-up-the-registry

    It will be useful.

    Let us know if you encounter problems with Windows in the future. We will be happy to help you.

  • [win] [js] [cs4] find/replace the paragraph styles without losing the replacements the

    Hi guys I need some help here.

    I created a javascript script that will find and replace paragraph styles for the DOCFILE with indesign paragraph styles. everything works fine but the problem is that, when she applies paragraph styles, he loses all replacements the. I tried:

    changetext (false);

    but his does not work, this is a kind of conditional parameter that I can put in the function changetext() so that it used clear local overrides?

    Thank you.

    Horse

    Use findGrep() (or findText()) instead of changeText(). This returns an array of items found. Then, you can loop through the array and apply a paragraph style without erasing the replacements (the 2nd parameter must be false).

    Example:

    Main();
    
    function Main() {
        var foundItem;
        var doc = app.activeDocument;
    
        app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
    
        app.findGrepPreferences.findWhat = ".+";
        app.findGrepPreferences.appliedParagraphStyle = "Body text";
    
        var foundItems = doc.findGrep();
    
        for (var i = 0; i < foundItems.length; i++) {
            foundItem = foundItems[i];
            foundItem.applyParagraphStyle(doc.paragraphStyles.item("Body"), false);
        }
    
        app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
    }
    
  • AppleScript to apply styles of table and cell in IDCS4

    I have an Applescript script to format all the tables in a document as I want.  It is adapted from a previous version that did not use styles, that works perfectly.  This script creates styles if they are not present and this bit works fine, but when it starts to try to apply them to the tables, it falls.

    tell application "Adobe InDesign CS4"
         tell active document
              set BlackColor to color "Black"
              set SolidStroke to stroke style "Solid"
         end tell
         tell active document
              try
                   set myTablePara to paragraph style "4.2 Table text"
              on error
                   set myTablePara to make paragraph style with properties {name:"4.2 Table text", applied font:"Helvetica Neue", font style:"Regular", point size:"8.5", leading:"10"}
              end try
              try
                   set myBasicCell to cell style "Basic cell"
              on error
                   set myBasicCell to make cell style with properties ¬
                        ¬
                             {name:¬
                                  "Basic cell", bottom edge stroke weight:0 ¬
                                  , bottom edge stroke color:BlackColor ¬
                                  , bottom edge stroke type:SolidStroke ¬
                                  , right edge stroke weight:0 ¬
                                  , right edge stroke color:BlackColor ¬
                                  , right edge stroke type:SolidStroke ¬
                                  , top edge stroke weight:0 ¬
                                  , top edge stroke color:BlackColor ¬
                                  , top edge stroke type:SolidStroke ¬
                                  , left edge stroke weight:0 ¬
                                  , left edge stroke color:BlackColor ¬
                                  , left edge stroke type:SolidStroke ¬
                                  , left inset:¬
                                  "0p4", right inset:¬
                                  "0p4", top inset:¬
                                  "0p4", bottom inset:¬
                                  "0p4", vertical justification:top align ¬
                                  , applied paragraph style:myTablePara}
              end try
              try
                   set myHeader to cell style "Header"
              on error
                   set myHeader to make cell style with properties ¬
                        {name:¬
                             "Header", based on:myBasicCell ¬
                             , bottom edge stroke weight:¬
                             "0.5pt", top edge stroke weight:"0.75pt", vertical justification:bottom align ¬
                             }
              end try
              try
                   set myFooter to cell style "Final Row Cell"
              on error
                   set myFooter to make cell style with properties ¬
                        {name:¬
                             "Final Row Cell", based on:myBasicCell ¬
                             , bottom edge stroke weight:¬
                             "0.75pt"} ¬
                             
              end try
              try
                   set myLeftCol to cell style "First Column Cell"
              on error
                   set myLeftCol to make cell style with properties ¬
                        {name:"First Column Cell", based on:myBasicCell, left inset:0}
              end try
              try
                   set myLeftHeader to cell style "First Row, First Column Cell"
              on error
                   set myLeftHeader to make cell style with properties ¬
                        {name:"First Row, First Column Cell", based on:myHeader, left inset:0}
              end try
              try
                   set myLeftFooter to cell style "First Column Last Row Cell"
              on error
                   set myLeftFooter to make cell style with properties ¬
                        {name:"First Column Last Row Cell", based on:myFooter, left inset:0}
              end try
              
              try
                   set myTableStyle to table style "Horizon"
              on error
                   set myTableStyle to make table style with properties {name:¬
                        "Horizon", body region cell style:¬
                        myBasicCell, header region cell style:¬
                        myHeader, footer region cell style:¬
                        myFooter, left column region cell style:myLeftCol}
              end try
         end tell
         set allTables to every table of every story of active document
         repeat with i from 1 to count of allTables
              set myTable to item i of allTables
              set table style of myTable to myTableStyle
              set properties of cells of myTable to ¬
                   {cell style:myBasicCell}
              set properties of cells of first column of myTable to ¬
                   {cell style:myLeftCol}
              set properties of cells of first row of myTable to ¬
                   {cell style:myHeader}
              set properties of cells of last row of myTable to ¬
                   {cell style:myFooter}
              set properties of first cell of first row of myTable to ¬
                   {cell style:myLeftHeader}
              set properties of first cell of last row of myTable to ¬
                   {cell style:myLeftFooter}
              clear cell style overrides
              clear table style overrides
         end repeat
    end tell
    

    When it is to 'set style table of myTable to myTableStyle' it is said ' impossible to define style table id of the table to text frame id page id 220 190 of spread id 185 [the first table] document \"Untitled-1\" table style id 264 [style newly generated] document \"Untitled-1\" 224 "  But I can't tell why.  Can anyone help?

    Table and cell styles are objects. When you want to apply, you must set the appropriate properties that are 'applied the style of table"and"cell style ". So: «the game applied style table myTable...» »

    But in terms of results, you'll be probably happier using the commands ' apply the style of table cell / ' instead, which allows you to clear the replacements.

    --

    Shane Stanley [email protected]>

    AppleScript Pro Sessions http://scriptingmatters.com/aspro>

Maybe you are looking for

  • nightmare of backlit

    Began shooting a scene near a window in the morning, broke for lunch, then returned to PM to finish.  Did not notice at the time how sunny it was outside.  Long story short: the best shots are in PD and the window a terrible hot spot.  Someone at - i

  • Question DLNA on TV 46TL938G

    Hi all, I have a Toshiba 46TL938G TV. I have the following problem. I want to stream movies via the media network (DLNA). With each movie, I get a media error. They are. MKV file. With DVD format obtained. When I put on an external HD mkv files and c

  • LaserJet P1102: laserjet 1102 does not pdf print

    I can't print pdf files using the print dialog buttons... I guess that there is a conflict/bug in Adobe Reader

  • HP Advisor alert does not

    Hello I installed windows 7 on my laptop. After you install the updates, the HP Advisor appears, but does not. In addition, it says 2 recommended alerts require your attention. It's boring because it is whenever I restart the computer. What could be

  • BlackBerry Smartphones not receive all notifications from Facebook on my Blackberry Storm 9530

    I have the latest version of the OS and Facebook and I have the following problems: I receive all notifications via the application as I would live or if I was disconnected from the application and just like the emails go to my Blackberry (it seems t