Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all articles
Browse latest Browse all 37788

Re: Script to search for text and remove hyperlink and characterstyle that is applied (return to normal)

$
0
0

You are a beuatiful person! That worked perfectly!

 

Here is my final code (for anyone who later wants to use this):

 

main();

 

function main() {

    var myDialog = app.dialogs.add({name: "Search for the user submitted text and remove hyperlinks from found items.", canCancel: true});

    with(myDialog) {

        with(dialogColumns.add()) {

            with(borderPanels.add()) {

                staticTexts.add({staticLabel: "Search and remove hyperlinks for:"});

                var myTextBox = textEditboxes.add({minWidth:200});

            }

        }

    }

 

    if (myDialog.show() == true) {

        var myDocument = app.activeDocument,

                noneStyle = myDocument.characterStyles.item(0),

                myHyp = myDocument.hyperlinks.everyItem().getElements(),

                len = myHyp.length,

                myFindVal = myTextBox.editContents,

                myCount = 0;

 

        while (len-->0)

            if (myHyp[len].source.hasOwnProperty("sourceText") && myHyp[len].source.sourceText.contents == myFindVal) {

                myHyp[len].source.sourceText.appliedCharacterStyle = noneStyle;

                myHyp[len].source.sourceText.clearOverrides(OverrideType.ALL);

                myHyp[len].remove();

                myCount++;

            }

 

        alert("Done! Part hyperlinks have been removed for: '" + myFindVal + "'! (Hyperlinks removed: " + myCount + ")");

    }

    myDialog.destroy();

}


Viewing all articles
Browse latest Browse all 37788

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>