FindChangeByList.jsx?

Can someone point out the FindChangeByList.jsx provided with Indesign?  Mine for some reason any is sent errors.

also download here

The InDesign developer documentation | Adobe Developer Connection

Tags: InDesign

Similar Questions

  • When I try to run a FindChangeByList.jsx in InDesignCS4, it won't let me choose a txt file

    Hi all

    I have a 100 page document that uses two queries to javascript FindChange to clean an imported XML file. I use the same files to clean for years and they worked very well. (I still only open in CS4 because I had some problems when you try to use this combo XML/find-replace in CS5 and 6.) The only difference is my computer has been upgraded, the apps reinstalled and am now running 10.9.5

    I can import the XML very well in my template, but when I double click FindChangeByList.jsx, select Document, click OK, nothing happens. I do not get a second dialog box asking me to choose my cleanup of txt file.

    I have only run this job once a year, so it's possible that I'm doing something wrong. I have copies of my txt files place in as many scripts as I can find it on my computer, but they are greyed out in support FIndChange file in InDesign.

    Please help, it's the only way to correct this XML!

    Hello

    2 things:

    1. assuming that your script is original - it is not by asking a TXT file grow is in the expected location. You can choose between 2 options:

    • to remove FindChangeList.txt of FindChangeSupport file ==> script will ask another file
    • to replace this file with your request ==> script won't ask but to run your query

    2. you can see greyed TXT files in the Script Panel since this panel shows the executable files (the script formats)

    Jarek

  • The difference between the "Find and replace" in the menu and FindChangeByList.jsx

    Hello! Please help me. Why this work ' find and replace ' (grep), but not working in FindChangeByList.jsx

    find replace
    \r\d (.) \D\d0$ 0

    This procedure find enter, any digit, any digit, any digit and replace all in 0, found.

    Example:

    front after

    7.35

    0

    7.35

    But it does not work in FindChangeByList.jsx (file: FindChangeList.txt):

    grep{findWhat: "\r\d (.)} \D\d"}{changeTo: "0$ 0"}{includeMasterPages:true, includeHiddenLayers:true, includeFootnotes:true, wholeWord:false}

    And it does not work in the present:

    myDocument var = app.documents.item (0);

    app.findGrepPreferences = NothingEnum.nothing;

    app.changeGrepPreferences = NothingEnum.nothing;

    app.findChangeGrepOptions.includeFootnotes = false;

    app.findChangeGrepOptions.includeHiddenLayers = false;

    app.findChangeGrepOptions.includeLockedLayersForFind = false;

    app.findChangeGrepOptions.includeLockedStoriesForFind = false;

    app.findChangeGrepOptions.includeMasterPages = false;

    app.findGrepPreferences.findWhat = \r\d (.) « \D\d » ;

    app.changeGrepPreferences.changeTo = "0$ 0";

    myDocument.changeGrep ();

    Please help me understand. Thank you!

    in findChangeByList you have to escape the string:

    {findWhat : » \d(.) \r\\ \\d\\d"}

  • FindChangebyList.jsx has recently stopped working

    Hello

    I very often use the FindChangebyList.jsx (standard script that ships with InDesign). He recently launched an error that I can not solve problems . Anyone has any ideas on what's going on? Running InDesign CS5.0 worm 7.0.4 Windows 7. It looks like something to do with preferences, perhaps a preferences clear user is in order?

    Window Capture.png

    This may or not that it is, but I ran into a similar problem when FindChangeByList is researching or editing a paragraph or character style that is not available in your current document.

  • Codes FindChangeByList.jsx and properties for INDD

    0Hi,

    Is there a way to know what "Search and modify properties" (in java/.jsx format) is applicable thorugh Notepad.txt for scripting Indesign CC 2015?

    For example:

    A list of properties/commands I can use in FindChangeByLIst.txt?... .such as:
    appliedFont (to change a font)

    pointSize (to change the fontsize)

    appliedStyle (to change the style of a font) and so on... is there a list of such description to properties like that?

    Would make the work more efficient.

    Future prospects for any help on this, thanks.

    Like, rachida

    You can search this Web site:

    InDesign ExtendScript API (11.0)

    Or download iChm files or HTML files (InDesign CS6 and below) for the documentation of DOM (Document Object Model) created by Jongware here:

    InDesign JavaScript help

    Especially check the section of the text Suite :

    InDesign ExtendScript API (11.0)

    In my view, there is no list explicitly for FindChangeByList.

    Uwe

  • Need help to modify the findchangebylist.jsx script

    I alternate the same script vbs to meet my needs and I was happy about it (likeChild when you give him his favorite toy) but I run into som problems with when I copy and place the script vbs on another computer I want to using it called CS6 instead of CC... I tried everything I could think of but no luck... same thing happens whenever I try to use CS6 open rather CC in which I run it... on the computer I write the script running like charm (on both computers, I have CS6 and CC)... so I decided to use the same script jsx version...

    then, when I try this script:

    1. the dialog box opens only when my cursor is textframe allowing me to select what I want to change the selected item 2. 1 document. 3 selection

    2. when I select 2 blocks of text and document I have 3 or more, the script does not change in 2 pictures selected instead she does in all settings

    I need to rotate this script

    When I select the text block to open dialogbox allow me to take 2/3 of the options mentioned above, the number 2 and 3

    He doesn't find it and change only in blocks of text I selected (when it is selected with the Selection tool) not in all settings

    I tried to do it my self, but a little short of knowledge im

    I tried to switch the dialog case is open, adding the line case 'TextFrame': in this part of the script

    If (app.documents.length > 0) {}

    If (app.selection.length > 0) {}

    {Switch(App.Selection[0].constructor.) Name)}

    case 'PointInsertion ':

    'character ': case

    case "word":

    case 'TextStyleRange ':

    case "line":

    stops of the "Point":

    case "TextColumn":

    case 'text ':

    case "cell":

    case "column":

    case 'Row ':

    case 'Table ':

    myDisplayDialog();

    and it works to call the dialog box when the text block is selected, but then he didn't make changes textframe don't debut not overall selected...

    So I tried to experiment with this line

    if(myResult == true) {}

    {Switch (myRangeButtons.selectedButton)}

    case 0:

    myObject = app.documents.item (0);

    break;

    case 1:

    MyObject = app.selection [0] .parentStory;

    break;

    case 2:

    myObject = app.selection [0];

    break;

    }

    myDialog.destroy ();

    myFindChangeByList (myObject);

    }

    else {}

    myDialog.destroy ();

    }

    by changing the number 1, 2 or 3, but that only the script says that if I have 2 block of selected text to search in the second block of text (incase of number 1) or if I have selected 3 and if numer 2 only script in text 3

    I need help please

    Hello

    I ment something like this:

    //...
    var myResult = myDialog.show();
      if(myResult == true){
           switch(myRangeButtons.selectedButton){
                case 0:
                     myObject = app.documents.item(0);
                     myFindChangeByList(myObject);
                     break;
                case 1:
                     if (app.selection[0].constructor.name == "TextFrame")
                          for (var b = 0; b < app.selection.length; b++)  {
                               myObject = app.selection[b].parentStory;
                               myFindChangeByList(myObject);
                          }
                     else {
                          myObject = app.selection[0].parentStory;
                          myFindChangeByList(myObject);
                          }
                     break;
                case 2:
                     myObject = app.selection[0];
                     myFindChangeByList(myObject);
                     break;
                }
           myDialog.destroy();
           }
           else {
                myDialog.destroy();
           }
    //...
    

    App.Selection is a table, but its length is always a number.

    If the 1st element of selection is a TextFrame (or more) ==>, we get into a loop

    on the other ==> we call a function that had been initially.

    Jarek

  • Call in filename different .txt, FindChangeByList

    On my home computer, I used the FindChangeByList.jsx script that Adobe provides with InDesign. He calls in a .txt file named "myFindChangeByList." (in a folder called "FindChangeSupport") I saved a copy in the same folder and add my own search/replace items for a specific project. When you run the script, he sees there are two .txt files in the folder and ask you which one you want to run. I choose the 2nd, and it runs great.

    However, I am using the file to work. When I try to add the second .txt file to the FindChangeSupport folder, I need administrator rights. I have to call him and get permission every time I wanted to change the file or add a different .txt file.

    I tried to name all references to my second file name .txt file, but it does not work.

    I don't know anything about scripts, so I was wondering:

    Is it possible in the script (jsx) file to call in my 2nd file .txt anywhere I save it?

    Here is the beginning of the script .jsx - the file is listed/called several times all throughout. I guess I need to change all references to it?

    main();

    main() {} function

    var myObject;

    Ensure that the interaction of the user (dialog boxes display, etc.) is turned on.

    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

    If (app.documents.length > 0) {}

    If (app.selection.length > 0) {}

    {Switch(App.Selection[0].constructor.) Name)}

    case 'PointInsertion ':

    'character ': case

    case "word":

    case 'TextStyleRange ':

    case "line":

    stops of the "Point":

    case "TextColumn":

    case 'text ':

    case "cell":

    case "column":

    case 'Row ':

    case 'Table ':

    myDisplayDialog();

    break;

    by default:

    An option has been selected, but it was not a text object, so look for in the document.

    myFindChangeByList (app.documents.item (0));

    }

    }

    else {}

    Nothing has been selected, then just search for the document.

    myFindChangeByList (app.documents.item (0));

    }

    You can just copy the script and the file 'FindChangeSupport' from the Application folder (Adobe InDesign CSX\Scripts\Scripts Panel\Samples\JavaScript) to your user > actions panel folder. Easy access to both files in the Scripts Panel by right-clicking on the name of the folder and choosing reveal in Explorer/Finder

  • Problem with - FindChange_Record_CS3.jsx

    CS4 OSX 10.5.8

    I use the "FindChange_Record_CS3.jsx" script to generate a custom text file "FindChangeByList.jsx".

    It seems that saved queries, generated from 'FindChange_Record_CS3.jsx', for some reason, do not include a path to the styles of character and paragraph inside 'Group of Style' elements. Although they work perfectly well because they are in demand.

    If I move the relevant paragraph and character out of their 'group' styles in the root of the character styles and paragraph the query works fine.

    Could someone please tell me how to insert the proper syntax for the "bits" that are absent from what follows, as the character "Body text italic" style resides in a folder of the group called "Body text", and the paragraph style "body text 10/12 SwissLtBt - Standard" lives in a folder group called "main text"?

    grep {findWhat: "(.+) ', fontStyle:" italic"} {changeTo: '$1', appliedCharacterStyle:"Body italic text", appliedParagraphStyle:" body text 10/12 SwissLtBt - Standard", changeConditionsMode:1919250519"} {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:true} //Comment

    BTW. -"changeConditionsMode:1919250519" mean?

    AAMT Steve

    grep [Tab] {findWhat: "(.+) ', fontStyle:" italic"} [Tab]

    {changeTo: '$1', appliedCharacterStyle:app.activeDocument.characterStyleGroups.item ("Body text") .characterStyles .item ("Body text italic"), appliedParagraphStyle:app.activeDocument.paragraphStyleGroups.item ("Main text") .paragraphStyles .item ("body text 10/12 swissltbt-standard")} [Tab] {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:true}

    I've tested this on CS3, Win - hope it should work for CS4, Mac.

    P. S.

    -"changeConditionsMode:1919250519" mean?

    changeConditionsMode - the lifestyle change of conditions, change replaces the stipulated conditions or adds to the conditions specified.

    Can be:

    ChangeConditionsModes.ADD_TO Change adds the conditions specified.
    ChangeConditionsModes.REPLACE_WITH Changing conditions replace applied. (Same as changeConditionsMode:1919250519)

    or

    ChangeConditionsModes.NothingEnum.NOTHING

    I think you can just omit it if you do not use the conditional text feature.

    Kasyan

  • Slow down the script

    Hello world

    When you run a script as "FindChangeByList.jsx" included in InDesign, is possible to edit and do show you next change and wait for change you to click the button? How it would be written in javascript?

    Secondly, is it possible to run a script (such as FindChangeByList.jsx) and have it tell you how many changes have been made (in a dialog window)?

    Mike Witherell in Maryland

    If you look in the code, you can see the functions "myFindText", "myFindGrep" and "myFindGlyph" all store them the results of the real myObject.changeXXX(..) in a variable called myFoundItems . This will be an array of the amended text (and it is not used anywhere. Eh_bien, these are just example scripts.). The number of changes is the length of the array: myFoundItems.length.

    You can:

    1. Add a global variable at the top, before the line "main()":

    var NumberOfChanges = 0;
    

    2 at the end of each of the routines myFindXXX, add a line

    NumberOfChanges += myFoundItems.length;
    

    3 Add an alert at the top, after the line "main()":

    alert ("Number of changes made: "+NumberOfChanges);
    

    Not tested, but it should work.

    Regarding your other point, a manual to confirm for each find/replace separate: it's much, much more work. It must be remembered that InDesign JavaScript do not "drive" the interface (like a macro), but makes rather direct calls in the underlying code. The Find/Replace dialog box is never "so-called", and there is no possibility of in kind 'pause' in the middle of the operation and to show the State of this dialog box.

    Unfortunately, Adobe programmers did not add orders for 'find next' and "change, to find the next" to its script interface. You can search or replace, nothing else. It is possible to use a find all first and then, roll on its results and manually choose the occurrences of change, but each time you change something, all previously found list is invalidated! There is no easy way of 'continue' looking for any random starting point either (and frankly, it seems a recurring problem for Adobe programmers, because in the interface itself is also quite irregular sometimes!).

    Can you tell us more about what is the substance of your question?

  • External GREP list. Is this possible?

    Here, in our society, we have a series of governing legal publications for the tender. Our job is to make small summaries of the journal. We have a lot of them every day. And we use "BOLD" / CAPS in a few words, as you guys can see in the JPG below.

    We have a standard file used as a template. This standard file has a style for the main text with a large list of words GREP where a "BOLD" / CAPS is applied. But sometimes we have new words to add to this list of GREP. And that pannel GREP is not the best way to change information so much of.

    Is it possible to use an external file where we can change, add or delete these words?

    bidding.jpg

    It can be done easily! FindChangeByList.jsx or Multi-Find/change plugin I think immediately!

  • My first script needs help

    Text < tab > {findWhat: '< U + 0394 >'} < tab > {appliedCharacterStyle: 'Symbol'} < tab > {includeFootnotes: true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}

    In this case, I want to exchange the Greek letter Delta, which is the code point U + 0394, for a specific character style (the style is called symbol).

    The question is: is written right?

    Where should I put it? Because I'm just add this line to an existing code...

    Thanks anyway for everyone! ^^

    Hello

    You can use the "grep" instead of "text". I mean:

    grep{findWhat: "\x 394 {}" ""}{appliedCharacterStyle: 'Symbol'}{includeFootnotes:t Street, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}

    findWhat: "\x 394 {}" means to find a unicode with defined number (the number you see in the Panel Info InDesign).

    It must be placed as one of the lines inside the file "FindChangeList.txt" before "FindChangeByList.jsx" run.

    Jarek

  • Remove the scaling of fonts - need help with FindChangeList.txt

    First the whole question: is there a utility or a method that will allow me to convert a saved query F/c the kind of writing required by the FindChangeByList.jsx script?

    As:

    text{"findWhat: '-'"}{"changeTo: '" ^ = "}{includeMasterPages:true, includeHiddenLayers:true, includeFootnotes:true, wholeWord:false}Find out all the space-dash-space and replace it with an en dash.

    (It comes just to refresh your memory... in fact, it is not the text string I need to help, but find/changes formatting.)

    I need a quick way to go through a document and remove any instance of glyph local scale or style. That is, to turn again to 100% horizontal and vertical. This is necessary for the correct exit to EPUB (fixed provision).

    A script would be great, but who, a way to write about this kind of implementation in the form of instructions to add to FindChangeByList.jsx would serve me well in the long term, as I have other similar types of doc-all of the formatting I often need to make default

    Thank you

    AM

    For your first question, you can use the find/replace registration script...
    http://InDesignSecrets.com/find-change-scripting-goodness.php

  • Read a line in a txt file

    Hi all

    I need to know how to read entire of any txt file lines. For example, I have this in a txt file:

    testline1

    testline2

    testline3

    and I need to read only the line 2 (text "testline2").

    I know how to read the file:

    var file = File(app.activeScript.parent.fsName + '/test.txt');
    file.open("r");
    var str = file.read(); // whole content of "test.txt" is now in variable "str"
    file.close();
    

    but I don't know how to read ONLY for example to line 2. Can you help me with this someone please?

    Thank you very much in advance

    1. use the function of a file object readln: Adobe InDesign CS6 (8,0) object model JS: file

    2. look in the sample scripts; FindChangeByList.jsx uses "readln".

  • Color of find/replace Word

    I use InDesign CS5 on a mac.

    I have set up a GREP search to replace the Word colors with the colors, I defined in InDesign. Works fine when I run it in InDesign. However, when I put the search in the FindChangeList.txt file and run the FindChangeByList.jsx script, I always get an error. He said: this is the error #17, line 172:

    app.doScript (myString, ScriptLanguage.javascript);

    Anyone know why?

    It comes to research, I put in the .txt file:

    grep {, fillColor: "Word_R0_G128_B0"} {, fillColor: "Black"} {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:true, kanaSensitive:true, widthSensitive:true} //Replace Color Word

    I came across several posts that say there are several free scripts that can run saved queries to GREP all at once, but they list the names of script or link to everything. Does anyone know a script that combines queries?

    I think that it will fire on the part '{, '. Commas go between values, but you only have a single value. Just out this comma before "fillColor", in both places.

  • Misfortunes placing text; need your experience! [CS4 + JS]

    Hello - I'm working on a routine for the import of a number of text documents in InDesign, but concocted with strange behavior when you move the text. I work with ID CS4 & javascript; all actions performed the same when you do them manually.

    I start with the text - no actual formatted text from a Word document, but saved as a text file - and with the up tool to text at the position of the cursor in a paragraph in style "body text"; the text includes different formatting from style, namely the "Headline" style police, although that leader & pt size are always style "body text".

    Yet when I cut the text of a text editor, then paste it to the location of the cursor, the text appears as I hope, in the body text style no substitutions.

    It is a small improvement: when I first tried to place the text, he had been forthcoming with an applied character style. I noticed that the character style has been selected in the fast application menu. Not by selecting the character in the fast application style has made me to where I am now.

    It's driving me crazy that I have still can't understand the police Headline-style! Pointers?

    Thanks in advance...

    Daniel

    PS: I try the import of text angle to avoid other problems I had been importing Word documents, namely import any document Word97-2003 with the highlighted text would break ID, character styles to Word adding direct formatting to the text in ID, etc.

    As promised, here is the code as it is, for any possible help. The code is specific to my special uses, but the approach to marking of the different styles of direct/character of the word, wiping all formatting and then reapply the styles of ID and remove the tags may be useful.

    /*
        ConvertWordBrute.jsx
    
        Problem: importing from regularly styled Word templated documents to CS4 can be a mess. Even if import presets are exactly set,
        if the Word doc has character styles, text can come in with layered character styles. Applying correct character styles and then
        removing  overrides won't fix because character styles and direct formatting are layered on every bit of text and formatting is not
        at all standard. To fix, all character styles AND overrides must be removed to wipe out the strangeness. This script shows one approach
         to keep italic, bold and bold italic direct formatting, and perhaps other stuff to preserve what the writers intended.
    
        The approach: tag formatting outside of ID's usual facilities, wipe all formatting clear, then apply the proper styles & character styles.
    
        Presumes:
            --A word import preset has been set...
            --Will need to trap for missing fonts? (e.g. Windings Bold, which is faked in Word; doesn't actually exist!)
            Left @: Works reasonably well. Probably should be run on before layout has sections.
            --Document includes a paragraph style named "Body Text"
    */
    /**
    * @@@BUILDINFO@@@ ConvertWordBrute.jsx !Version! Thu Oct 11 2011 10:52:08 GMT-0700
    */
    
    #script "ConvertWord"
    #target "InDesign"
    
    main();
    
    function main(){
        try {
            var docRef = getActiveDocument();
        } catch (e) {
            alert (e);
        }
        var confirmWarning = "Note: bold, italic and bold-italic will be turned into character styles, then this script clears all overrides--" +
            "any character spacing applied outside of regular paragraph and character styles will be erased--OK?";
        var myConfirm = confirm(confirmWarning, true, "Text change alert!");
        if (myConfirm == false){
            return;
        }
        var jumpTextCharStyle = "Body jump text";
        var jumpLineChars = 30;
    
        //saveTextReflowState & turn it off to avoid adding pages...
        var smartTextReflowState = docRef.textPreferences.smartTextReflow
        docRef.textPreferences.smartTextReflow = false;
    
        //Apply HTML-like tags to text with formatting you want to keep
        //what you search here depends on how your import preferences were set... did you map incoming word styles? to what? Normal -> Body Text?
        tagFormattedCharacters(docRef, "Body Text", "Bold" , "b");
        tagFormattedCharacters(docRef, "Body Text", "Italic" , "i");
        tagFormattedCharacters(docRef, "Body Text", "Bold Italic" , "bl");
        tagFormattedCharacters(docRef, "Normal", "Bold" , "b");
        tagFormattedCharacters(docRef, "Normal", "Italic" , "i");
        tagFormattedCharacters(docRef, "Normal", "Bold Italic" , "bl");
        tagFormattedCharacters(docRef, "Body Text indent", "Bold" , "b");
        tagFormattedCharacters(docRef, "Body Text indent", "Italic" , "i");
        tagFormattedCharacters(docRef, "Body Text indent", "Bold Italic" , "bl");
        cleanupTags(docRef);
    
        //Convert Word styles to ID styles, then wipe Word styles
        convertWordStyles(docRef);
    
        //Re-apply all paragraph styles with no overrides or character styles
        formatTaggedCharacters(docRef, "b", "Bold")
        formatTaggedCharacters(docRef, "i", "Italic")
        formatTaggedCharacters(docRef, "bl", "Byline")
    
        // Replace jump lines character style, since above makes all bold-italic into Byline style
        formatJumpLines(docRef, jumpLineChars, jumpTextCharStyle);
    
        //re-instate text reflow
        docRef.textPreferences.smartTextReflow = smartTextReflowState;
    
    }
    
    function getActiveDocument(){
    //returns reference to active document; otherwise undefined
        //if a variable is not assigned a value, its value is undefined
        if (app.documents.length == 0) {
            throw ("No documents open");
        }
        //returns value for variable docRef back to call statement
        var docRef = app.documents.item(0);
        return docRef;
    }
    
    function tagFormattedCharacters(docRef, paragraphStyle, fontStyle, fontTag) {
        // Searches for characters in paragrapfStyle, fontStyle in docRef, enclosing any characters found
        // in HTML-style angle-bracket tags containing fontTag
        var myStyles, s, stylesRE;
    
        //First chk if passed paragraphStyle exists
        for (var s = docRef.paragraphStyles.length-1; s >= 2; s--) {
            //get a list of pipe-separated styles, but not the default styles in brackets, since they'll screw up a RegExp pattern
         myStyles = docRef.paragraphStyles[s].name + "|" + myStyles;
       }
        stylesRE = new RegExp(myStyles);
        if (!paragraphStyle.match(stylesRE)){
            return;
        }
        //Clear the find/change preferences.
        clearFindChangePrefs()
    
        //Set the find options.
        app.findChangeTextOptions.caseSensitive = false;
        app.findChangeTextOptions.includeFootnotes = false;
        app.findChangeTextOptions.includeHiddenLayers = false;
        app.findChangeTextOptions.includeLockedLayersForFind = false;
        app.findChangeTextOptions.includeLockedStoriesForFind = false;
        app.findChangeTextOptions.includeMasterPages = false;
        app.findChangeTextOptions.wholeWord = false;
        app.findTextPreferences.appliedParagraphStyle = paragraphStyle;
        app.findTextPreferences.fontStyle = fontStyle;
    
        var myFoundItems = docRef.findText();
        openTag = "<"+fontTag+">";
        closeTag ="";
    
        //Note: gotta iterate from the end forward, otherwise tag insertions will skew insertion points
        for(i=myFoundItems.length-1; i>-1; i--){
            myFoundItems[i].insertionPoints.lastItem().contents = closeTag;
            myFoundItems[i].insertionPoints.firstItem().contents = openTag;
        }
    }
    
    function cleanupTags(myObject){
        // To correct for faulty formatting resulting in badly placed tags, e.g.: tags on both sides of paragraph returns.
        // To internalize search routines into this script, it uses a series of searches equivalent to FindChangeByList,
        // captured with RecordFindChange_CS3-CS5.jsx .
        // Note GREP search strings MUST be enclosed in quotes with all internal backslashes & quotes escaped,
        // e.g.: \\ becomes \\\\, findWhat:"( becomes findWhat:\"(
        var myChangesArray = new Array();
        // a few changes to clean up placement of formatting tags which may be funky from Word direct formatting
        myChangesArray[0] = "grep    {findWhat:\"(<[^>]*>)(\\\\s)(]*>)\"}    {changeTo:\"$2\", changeConditionsMode:1919250519}    {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false}"; //Nix bolded white space of any kind
        myChangesArray[1] = "grep    {findWhat:\"(<[^>]*>)(\\\\ )(\\\\[)\"}    {changeTo:\"$2$1$3\", changeConditionsMode:1919250519}    {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false}"; //move spaces (only!) in front of bylines before tag
        myChangesArray[2] = "grep    {findWhat:\"(\\\\r)(]*>)\"}    {changeTo:\"$2$1\", changeConditionsMode:1919250519}    {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false}"; //move close tags before graf returns
        myChangesArray[3] = "text    {findWhat:\"^_\"}    {changeTo:\"^_\", changeConditionsMode:1919250519}    {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false, wholeWord:false, caseSensitive:false}";    //Replace em dashes that somehow get bold italic
    
        findChangeByArray(myObject, myChangesArray)
    }
    
    function convertWordStyles(docRef){
        // Converts Word styles to ID styles, then wipes Word styles
        // To internalize search routines to this script, this uses a series of searches equivalent to FindChangeByList,
        // captured with RecordFindChange_CS3-CS5.jsx .
        // Note search strings MUST be enclosed in quotes with all internal backslashes & quotes escaped, esp. important for GREP
        // e.g.: \\ becomes \\\\, findWhat:"( becomes findWhat:\"(
        var i, p, stylesRE;
        var myChangesArray = new Array();
        //note: findChangeByArray does not trap for
        myChangesArray[0] = "text    {findWhat:\"^p^t\"}    {changeTo:\"^p\", changeConditionsMode:1919250519}    {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false, wholeWord:false, caseSensitive:false}"; // remove tabs at the start of paragraphs
        myChangesArray[1] = "text    {findWhat:\"n\", appliedParagraphStyle:\"Heading 1\", appliedFont:\"Wingdings\", fontStyle:\"Bold\"}    {changeTo:\"^8\", appliedCharacterStyle:\"[No character style]\", appliedParagraphStyle:\"Headline 1\", changeConditionsMode:1919250519}    {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false, wholeWord:false, caseSensitive:false}"; //replace square bullet in Heading 1 Word style to standard bullet Headline 1 + Bold
        myChangesArray[2] = "text    {appliedParagraphStyle:\"Normal\"}    {appliedParagraphStyle:\"Body Text\", changeConditionsMode:1919250519}    {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false, wholeWord:false, caseSensitive:false}"; // replace Normal paragraph Word style with Body Text
        myChangesArray[3] = "text    {appliedParagraphStyle:\"CallOut\"}    {appliedParagraphStyle:\"Callout\", changeConditionsMode:1919250519}    {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false, wholeWord:false, caseSensitive:true}"; // replace CallOut Word style with Callout
        myChangesArray[4] = "text    {appliedParagraphStyle:\"Normal Indent\"}    {appliedParagraphStyle:\"Body Text indent\", changeConditionsMode:1919250519}    {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false, wholeWord:false, caseSensitive:true}"; //replace Normal Indent Word style to Body Text indent
        myChangesArray[5] = "text    {appliedParagraphStyle:\"Body Text\", fontStyle:\"Italic\"}    {appliedCharacterStyle:\"Italic\"}    {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false, wholeWord:false, caseSensitive:false, kanaSensitive:true, widthSensitive:true, ignoreKashidas:true, ignoreDiacritics:false}"; //replace direct formatted body text italic with character style
        myChangesArray[6] = "text    {appliedParagraphStyle:\"Body Text\", fontStyle:\"Bold\"}    {appliedCharacterStyle:\"Bold\"}    {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false, wholeWord:false, caseSensitive:false, kanaSensitive:true, widthSensitive:true, ignoreKashidas:true, ignoreDiacritics:false}"; //replace direct formatted body text bold with character style
        myChangesArray[7] = "text    {appliedParagraphStyle:\"Body Text\", fontStyle:\"Bold Italic\"}    {appliedCharacterStyle:\"Byline\"}    {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false, wholeWord:false, caseSensitive:false, kanaSensitive:true, widthSensitive:true, ignoreKashidas:true, ignoreDiacritics:false}"; //replace direct formatted body text bold italic with Byline character style
        myChangesArray[8] = "text    {findWhat:\" -- \"}    {changeTo:\"^_\"}    {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false, wholeWord:false, caseSensitive:false, kanaSensitive:true, widthSensitive:true, ignoreKashidas:true, ignoreDiacritics:false}"; //replace space dash dash space with em dash, no spaces
        myChangesArray[9] = "text    {findWhat:\"--\"}    {changeTo:\"^_\"}    {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false, wholeWord:false, caseSensitive:false, kanaSensitive:true, widthSensitive:true, ignoreKashidas:true, ignoreDiacritics:false}"; //replace space dash dash space with em dash, no spaces
        myChangesArray[10] ="text    {findWhat:\"  \"}    {changeTo:\" \"}    {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false, wholeWord:false, caseSensitive:false, kanaSensitive:true, widthSensitive:true, ignoreKashidas:true, ignoreDiacritics:false}"; //replace double spaces with single space
        myChangesArray[11] ="text    {findWhat:\"^p^p\"}    {changeTo:\"^p\"}    {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false, wholeWord:false, caseSensitive:false, kanaSensitive:true, widthSensitive:true, ignoreKashidas:true, ignoreDiacritics:false}"; //Nix double paragraph markers
        // section to put in headline jump reference bullets
        myChangesArray[12] ="grep    {findWhat:\"\\\\>  ?(from \\\\[\\\\d\\\\d?\\\\])\\\\s?\\\\s?$\"}    {changeTo:\" ~8 $1\"}    {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:true, kanaSensitive:true, widthSensitive:true}"//add bullet before end of word, replace space (optional space) 'from [' digit optional digit ']' optional space optional space end of paragraph with space bullet space + the rest
    
        // Changes any imported paragraph styles to Body Text, imported character styles to None, nukes imported
        findChangeByArray(docRef, myChangesArray)
        removeImportedStyles(docRef);
        // clear overrides, both character & paragraph
        // first set what paragraphs to check
        stylesRE = new RegExp(/Body |Heading /)
        for (i = 0; i < docRef.stories.length; i++) {
            //only mess with stories with a bunch of paragraphs & only paragraphs of Body* or Heading* styles
            if (docRef.stories[i].paragraphs.length > 1) {
                for ( p=0; p < docRef.stories[i].paragraphs.length; p++){
                    if (docRef.stories[i].paragraphs[p].appliedParagraphStyle.name.match(stylesRE)) {
                        docRef.stories[i].paragraphs[p].clearOverrides(OverrideType.ALL);
                    }
                }
            }
        }
    }
    
    function clearFindChangePrefs(){
        //find/change text preferences
        app.findTextPreferences = null;
        app.changeTextPreferences = null;
        //find/change grep preferences
        app.findGrepPreferences = null;
        app.changeGrepPreferences = null;
        //find/change glyph preferences
        app.findGlyphPreferences = null;
        app.changeGlyphPreferences = null;
    }
    
    function findChangeByArray(myObject, myChangesArray){
        //a shorter version of the supplied FindChangeByList.jsx to allow internalizing search strings
        // Note search strings passed MUST be enclosed in quotes with all internal backslashes & quotes escaped,
        // esp. important for GREP, e.g.: \\ becomes \\\\, findWhat:"( becomes findWhat:\"(
        var myFindChangeArray, myFindType, myFindPreferences, myChangePreferences, myFindChangeOptions, i;
        var myStyles, s, stylesRE, searchOK;
        // Prepare to trap for non-existant styles
        // get a list of pipe-separated styles, but not the default styles in brackets, since they'll screw up a RegExp pattern
        for (var s = myObject.paragraphStyles.length-1; s >= 2; s--) {
             myStyles = myObject.paragraphStyles[s].name + "|" + myStyles;
       }
         stylesRE = new RegExp(myStyles);
        for (i = 0; i < myChangesArray.length; i++) {
            myFindChangeArray = myChangesArray[i].split("\t");
            //The first field in the line is the findType string.
            myFindType = myFindChangeArray[0];
            //The second field in the line is the FindPreferences string.
            myFindPreferences = myFindChangeArray[1];
            // Trap to ensure the style exists
            //The second field in the line is the ChangePreferences string.
            myChangePreferences = myFindChangeArray[2];
            //The fourth field is the range--used only by text find/change.
            myFindChangeOptions = myFindChangeArray[3];
    
            // Trap for non-existant paragraph styles; ID will choke on searching for a style not in doc
            // Look for paragraph style in find string
            if (myFindPreferences.match(/appliedParagraphStyle/)){
                // & that the search is for a style existing in the document
                if (!myFindPreferences.match(stylesRE)){
                    continue;
                }
            }
            switch(myFindType){
                case "text":
                    myFindText(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
                    break;
                case "grep":
                    myFindGrep(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
                    break;
                case "glyph":
                    myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
                    break;
            }
        }
    }
    
    function myFindText(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){
        //Reset the find/change preferences before each search.
        app.changeTextPreferences = null;
        app.findTextPreferences = null;
        var myString = "app.findTextPreferences.properties = "+ myFindPreferences + ";";
        myString += "app.changeTextPreferences.properties = " + myChangePreferences + ";";
        myString += "app.findChangeTextOptions.properties = " + myFindChangeOptions + ";";
        app.doScript(myString, ScriptLanguage.javascript);
        myFoundItems = myObject.changeText();
        //Reset the find/change preferences after each search.
        app.changeTextPreferences = null;
        app.findTextPreferences = null;
    }
    
    function myFindGrep(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){
        //Reset the find/change grep preferences before each search.
        app.changeGrepPreferences = null;
        app.findGrepPreferences = null;
        var myString = "app.findGrepPreferences.properties = "+ myFindPreferences + ";";
        myString += "app.changeGrepPreferences.properties = " + myChangePreferences + ";";
        myString += "app.findChangeGrepOptions.properties = " + myFindChangeOptions + ";";
        app.doScript(myString, ScriptLanguage.javascript);
        var myFoundItems = myObject.changeGrep();
        //Reset the find/change grep preferences after each search.
        app.changeGrepPreferences = null;
        app.findGrepPreferences = null;
    }
    function myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){
        //Reset the find/change glyph preferences before each search.
        app.changeGlyphPreferences = null;
        app.findGlyphPreferences = null;
        var myString = "app.findGlyphPreferences.properties = "+ myFindPreferences + ";";
        myString += "app.changeGlyphPreferences.properties = " + myChangePreferences + ";";
        myString += "app.findChangeGlyphOptions.properties = " + myFindChangeOptions + ";";
        app.doScript(myString, ScriptLanguage.javascript);
        var myFoundItems = myObject.changeGlyph();
        //Reset the find/change glyph preferences after each search.
        app.changeGlyphPreferences = null;
        app.findGlyphPreferences = null;
    }
    
    function removeImportedStyles(docRef){
        // Changes any imported paragraph styles to Body Text, imported character styles to None, nukes imported
       var paraStyle = docRef.paragraphStyles.item("Body Text");
       var noneCharStyle = docRef.characterStyles.item("[None]");
    
       for(var myCounter = docRef.paragraphStyles.length-1; myCounter >= 2; myCounter--){
         if (docRef.paragraphStyles[myCounter].imported == true ) {
            docRef.paragraphStyles[myCounter].remove(paraStyle); //Replaces w/paraStyle
         }
       }
    
       for(var myCounter = docRef.characterStyles.length-1; myCounter >= 2; myCounter--){
         if (docRef.characterStyles[myCounter].imported == true) {
            docRef.characterStyles[myCounter].remove(noneCharStyle);
         }
       }
    }
    
    function formatTaggedCharacters(docRef, fontTag, characterStyle){
        // Searches docRef for text between   tags & applies characterStyle
        // then removes the fontTags.
        // For characterStyle = Byline, If found text is greater than jumpTextLen in length, apply jumpTextCharStyle instead
        // First verify the passed charstyle exists...
    
        // use your standard GREP search & replace
        app.changeGrepPreferences = null;
        app.findGrepPreferences = null;
        // note ? mark in following GREP search string, the non-greedy modifier. Thanks Jongware!
        var myString = "app.findGrepPreferences.properties = {findWhat:\"<"+ fontTag + ">(.*?)<\/" + fontTag + ">\"};";
        myString += "app.changeGrepPreferences.properties = {changeTo:\"$1\", appliedCharacterStyle:\""+characterStyle+"\"};";
        myString += "app.findChangeGrepOptions.properties = {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:true};";
        app.doScript(myString, ScriptLanguage.javascript);
        var myFoundItems = docRef.changeGrep();
        //Reset the find/change grep preferences after each search.
        app.changeGrepPreferences = null;
        app.findGrepPreferences = null;
    
        //OK, the tags are still there, so wipe 'em
        removeTag(docRef, fontTag);
    }
    
    function removeTag(docRef, fontTag){
        // Use a GREP search to replace the given tag in docRef; don't mess with styles, as that should've been handled already
        // Reset the find/change grep preferences before each search.
        app.changeGrepPreferences = null;
        app.findGrepPreferences = null;
        var myString = "app.findGrepPreferences.properties = {findWhat:\"<"+ fontTag + ">(.*)<\/" + fontTag + ">\"};";
        myString += "app.changeGrepPreferences.properties = {changeTo:\"$1\"};";
        myString += "app.findChangeGrepOptions.properties = {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:true};";
        app.doScript(myString, ScriptLanguage.javascript);
        var myFoundItems = docRef.changeGrep();
        //Reset the find/change grep preferences after each search.
        app.changeGrepPreferences = null;
        app.findGrepPreferences = null;
    }
    
    function formatJumpLines(docRef, jumpLineChars, jumpTextCharStyle){
        //  Since previous convertWordStyles() changes all bold italic styled text to Byline char style, change any that are
        //  >jumpLineChars to 'Body jump text' style.
            app.changeTextPreferences = null;
            app.findTextPreferences = null;
            var myString = "app.findTextPreferences.properties = {appliedCharacterStyle:\"Byline\"};";
            myString += "app.findChangeTextOptions.properties = {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false};";
            app.doScript(myString, ScriptLanguage.javascript);
            var myFoundItems = docRef.findText();
            //Reset the find/change text preferences after each search.
            app.changeTextPreferences = null;
            app.findTextPreferences = null;
            //Note: best to iterate from the end forward, avoiding any potential insertion point skew
            for(i=myFoundItems.length-1; i>-1; i--){
                if (myFoundItems[i].length > jumpLineChars){
                    myFoundItems[i].appliedCharacterStyle = jumpTextCharStyle;
                }
            }
    }
    

Maybe you are looking for

  • Satellite L300/L300D - can't find WLAN

    I got this laptop for Christmas, but I can't get the wireless feature works. I downloaded the driver from Realtek LAN etc. but I still can't get a wireless network to be picked up Wireless switch is turned on. Any help much appreciated - I read thoug

  • I can't connect to Windows XP because I do not remember the password, I never asked before.

    When I turned on the computer using Windows XP, Microsoft Windows blue screen opens, tells me to click on my user name (that was) and then type my password.  I tried all the passwords I can think of, and none works.  Microsoft technical support shows

  • How to W - 810 iconia tablet 8 factory reset

    Decided to return the iconia Tablet 8 W - 810 to the seller because it is a problem with the sound, the retailer has no problem with it being returned. Obviously the tablet will have my username and password on etc. Is it far from the factory reset i

  • Office Jet Pro L7590 transport Jam

    I have inspected and you can't find any Jam... ideas?

  • Help me! HOW THE HP 430 LAPTOP BIOS SETUP?

    Who can help me! Please, I beg you! Thank you very much! I try to reinstall the window using usb but I can't configure bios to do this, I can't choose usb first... now I use Window 8.1!