• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Startup script that trigger on fontStyle Medium

Community Beginner ,
Mar 17, 2017 Mar 17, 2017

Copy link to clipboard

Copied

Hi there,

I have a startup script that has been given to me by an earlier collegue of mine.

I wonder if it's possible to change it to trigger only when fontStyle Medium are in the pasted frames?

Now it seems that it slows Indesign down when pasting.

#targetengine "texttvatt"

main();

function main() {

var myPaste = app.menuActions.item("$ID/Paste");

myPaste.addEventListener("afterInvoke", tvattMedium)

var myPasteInPlace = app.menuActions.item("$ID/Paste in Place");

myPasteInPlace.addEventListener("afterInvoke", tvattMedium)

}

function tvattMedium(){

var myDoc = app.activeDocument;

app.findTextPreferences = app.changeTextPreferences = null; 

app.findTextPreferences.fontStyle = "Medium";

app.activeDocument.pages.everyItem().pageItems.everyItem().locked = false;

var mySearch = myDoc.findText();

for(var i=mySearch.length-1; i>=0; i--){ 

    var myStyle = mySearch.appliedParagraphStyle; 

    if(myStyle.fontStyle != "Medium")

app.findTextPreferences = NothingEnum.nothing;

app.changeTextPreferences = NothingEnum.nothing;

    try {

        app.findTextPreferences.appliedParagraphStyle = myDoc.paragraphStyles.item("4 BODY");

        app.findTextPreferences.fontStyle = "Medium"

        app.changeTextPreferences.fontStyle = "Regular"

        }

        catch (myError) {}

    try {

        app.findTextPreferences.appliedParagraphStyle = myDoc.paragraphStyles.item("4 BODY anfang fet");

        app.findTextPreferences.fontStyle = "Medium"

        app.changeTextPreferences.fontStyle = "Regular"

        myDoc.changeText();

        }

        catch (myError) {}

    try {

        app.findTextPreferences.appliedParagraphStyle = myDoc.paragraphStyles.item("7 FAKTA recept body");

        app.findTextPreferences.fontStyle = "Medium"

        app.changeTextPreferences.fontStyle = "Regular"

        myDoc.changeText();

        }

        catch (myError) {}

    try {

        app.findTextPreferences.appliedParagraphStyle = myDoc.paragraphStyles.item("7 FAKTA text");

        app.findTextPreferences.fontStyle = "Medium"

        app.changeTextPreferences.fontStyle = "Regular"

        myDoc.changeText();

        }

        catch (myError) {}

app.findTextPreferences = NothingEnum.nothing;

app.changeTextPreferences = NothingEnum.nothing;

}

}

TOPICS
Scripting

Views

222

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 27, 2017 Mar 27, 2017

Copy link to clipboard

Copied

LATEST

Anyone with an answer?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines