Skip navigation
Currently Being Moderated

InCopy CS5 crash after the execution of a script

Nov 12, 2010 12:33 AM

Hi all,

I have problems with the execution of one script (you can find that at the end of the post) that make InCopy crash after this execution.

The strange thing is that if i execute that from the Extended Script Toolkit all works fine but if I try to execute that (with the same files) from a menù entry after his execution InCopy goes in crash..

 

I didn't find the InCopy CS5 crash report..where they are stored on Windows 7?

 

 

//Impostazione Preset documento di default
var myDocPresets = app.documentPresets;
var myDocPreset = myDocPresets.firstItem();
for (cont = 0; cont < myDocPresets.count(); cont++) {
    if(myDocPreset.name == "[Default]") {
        myDocPreset.textAreaWidth = 86.5;
    }
    myDocPresets.nextItem(myDocPreset);
}

#targetengine "session"

var myNormalizeTextAction = app.scriptMenuActions.add("Normalizza Testo");
var myEventListener = myNormalizeTextAction.eventListeners.add("onInvoke",
function(){
   
    var myDocument = app.activeDocument;    
    myDocument.importStyles(ImportFormat.textStylesFormat, File(myFilePath), GlobalClashResolutionStrategy.loadAllWithOverwrite);
    var myDialog = app.dialogs.add({name:"Normalizzazione del testo"});
    //Add a dialog column.
    with(myDialog){
        with(dialogColumns.add()){
            with(borderPanels.add()){    
                with(dialogRows.add()){
                    var myApplyDefStyle = checkboxControls.add({staticLabel:"Imposta stile di paragrafo base"});  
                }
                with(dialogRows.add()){
                    var myDoubleSpace = checkboxControls.add({staticLabel:"Sostituzione doppi spazi"});  
                }
                with(dialogRows.add()){
                    var myDoubleNL = checkboxControls.add({staticLabel: "Sostituzione doppi a capi"});  
                }
                with(dialogRows.add()){
                    var myCustom = checkboxControls.add({staticLabel: "Sostituzione personalizzata"});
                    with(dialogColumns.add()){ var myFindText = textEditboxes.add({maxWidth:10}); }
                    with(dialogColumns.add()){ var myChangeText = textEditboxes.add({maxWidth:10}); }
                }
            }
        }   
    }
    //Show the dialog box.
    var myResult = myDialog.show();
    //Display a message.
    if(myResult == true){

        var checkApplyDefStyle = myApplyDefStyle.checkedState;
        var checkDoubleSpace = myDoubleSpace.checkedState;
        var checkDoubleNL = myDoubleNL.checkedState;
        var checkCustom = myCustom.checkedState;
        var findCustomText = myFindText.editContents;
        var changeCustomText = myChangeText.editContents;
       
        //Remove the dialog box from memory.
        myDialog.destroy();

        //Impostazione dello stile di paragrafo di base
        if (checkApplyDefStyle == true) {    
            var myStories = myDocument.stories;
            var myStory = myStories.firstItem();
            for (cont = 0; cont < myStories.count(); cont++) {
                var myTexts = myStory.texts;
                var myText = myTexts.firstItem();
                var myDefaultStyle = myDocument.paragraphStyles.item("Interni_Txt_Book");   
                for (cont = 0; cont < myTexts.count(); cont++) {
                    myText.applyParagraphStyle(myDefaultStyle, true);
                    myTexts.nextItem(myText);
                }           
                myStories.nextItem(myStory);
            }
        }
        if (checkDoubleSpace == true) {   
            //Doppi Spazi
            //Clear the find/change preferences.
            app.findGrepPreferences = NothingEnum.nothing;
            app.changeGrepPreferences = NothingEnum.nothing;
            //Set the find options.
            app.findChangeGrepOptions.includeFootnotes = false;
            app.findChangeGrepOptions.includeHiddenLayers = false;
            app.findChangeGrepOptions.includeLockedLayersForFind = false;
            app.findChangeGrepOptions.includeLockedStoriesForFind = false;
            app.findChangeGrepOptions.includeMasterPages = false;
            //Regular expression for finding an email address.
            app.findGrepPreferences.findWhat = "[~m~>~f~|~S~s~<~/~.~3~4~% ]{2,}";
            app.changeGrepPreferences.changeTo = " ";
            myDocument.changeGrep()
            //Clear the find/change preferences after the search.
            app.findGrepPreferences = NothingEnum.nothing;
            app.changeGrepPreferences = NothingEnum.nothing;
        }
        if (checkDoubleNL == true) {   
            //Doppi A Capi
            //Clear the find/change preferences.
            app.findGrepPreferences = NothingEnum.nothing;
            app.changeGrepPreferences = NothingEnum.nothing;
            //Set the find options.
            app.findChangeGrepOptions.includeFootnotes = false;
            app.findChangeGrepOptions.includeHiddenLayers = false;
            app.findChangeGrepOptions.includeLockedLayersForFind = false;
            app.findChangeGrepOptions.includeLockedStoriesForFind = false;
            app.findChangeGrepOptions.includeMasterPages = false;
            //Regular expression for finding an email address.
            app.findGrepPreferences.findWhat = "~b~b+";
            app.changeGrepPreferences.changeTo = "\r";
            myDocument.changeGrep()
            //Clear the find/change preferences after the search.
            app.findGrepPreferences = NothingEnum.nothing;
            app.changeGrepPreferences = NothingEnum.nothing;
        }
        if (checkCustom == true) {   
            //Custom
            //Clear the find/change preferences.
            app.findGrepPreferences = NothingEnum.nothing;
            app.changeGrepPreferences = NothingEnum.nothing;
            //Set the find options.
            app.findChangeGrepOptions.includeFootnotes = false;
            app.findChangeGrepOptions.includeHiddenLayers = false;
            app.findChangeGrepOptions.includeLockedLayersForFind = false;
            app.findChangeGrepOptions.includeLockedStoriesForFind = false;
            app.findChangeGrepOptions.includeMasterPages = false;
            //Regular expression for finding an email address.
            app.findGrepPreferences.findWhat = findCustomText;
            app.changeGrepPreferences.changeTo = changeCustomText;
            myDocument.changeGrep()
            //Clear the find/change preferences after the search.
            app.findGrepPreferences = NothingEnum.nothing;
            app.changeGrepPreferences = NothingEnum.nothing;
        }
    }

});
var myMainMenu = app.menus.item("$ID/Main");
var myCustomMenu = myMainMenu.submenus.item("myMenu");
var myCustomMenuItem = myCustomMenu.menuItems.add(myNormalizeTextAction);

 

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points