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

Need help with this script please.

Advisor ,
May 02, 2016 May 02, 2016

Hi this works kinda.   I want the Find and replace to work with the Text Frames that i have selected only.  And if possible to get the Resize text part to only resize one time.  Right now if i keep clicking the Script it keeps shrinking the text and i only want it to fit 1 time.  Then after its done maybe say "Text alredy Formatted" Also i'm not sure if i did the description right.  I want it to tell what the script is when hover over it with my mouse.  Any help will be appreciated. 

//DESCRIPTION: Replace <CR> with Hard return/Resize Font to fit text frame

//Replaces("<CR>", "Hard Return") 

Replace(" <CR> ", "^p")             

    function Replace(input, output) 

     { 

        app.selection[0];

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

        app.findTextPreferences.findWhat = input; 

        app.changeTextPreferences.changeTo = output; 

        app.activeDocument.changeText(); 

       

    } 

     var myTextFrame = app.selection[0];

     var myText = myTextFrame.parentStory.texts[0];

     do {

       

         myText.pointSize = myText.pointSize - .01;

         } while (myTextFrame.overflows == true);

TOPICS
Scripting
969
Translate
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

correct answers 1 Correct answer

Guide , May 02, 2016 May 02, 2016

use this

Replace(" <CR> ", "^p")          

    function Replace(input, output)

    {

        app.selection[0];

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

        app.findTextPreferences.findWhat = input;

        app.changeTextPreferences.changeTo = output;

        app.activeDocument.changeText();

    

    }

    var myTextFrame = app.selection[0];

    var myText = myTextFrame.parentStory.texts[0];

try{

    do {

    

        myText.pointSize = myText.pointSize - .01;

    

...
Translate
Guide ,
May 02, 2016 May 02, 2016

use this

Replace(" <CR> ", "^p")          

    function Replace(input, output)

    {

        app.selection[0];

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

        app.findTextPreferences.findWhat = input;

        app.changeTextPreferences.changeTo = output;

        app.activeDocument.changeText();

    

    }

    var myTextFrame = app.selection[0];

    var myText = myTextFrame.parentStory.texts[0];

try{

    do {

    

        myText.pointSize = myText.pointSize - .01;

        } while (myTextFrame.overflows == true);

    }

catch(e){

    alert("Text already Formatted")

    }

Translate
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
Advisor ,
May 03, 2016 May 03, 2016

This did the same thing the one i pasted above.  I'm wanting it to resize the selected Text Frames. Usually just 2 or 3 text frames is all that needs resized.  Also Both texts only shrink text size. Is there a way to tell it to Fill the text frame by both Shrinking and expanding by .01?  Some text in the frames i'm using Will need a bigger font size inorder to fill the frame.  And the alert does not show up when i hit it a second time.

Translate
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
Advisor ,
May 03, 2016 May 03, 2016

NM i had to restart Indesign it is working fine.  but my other questions still apply..  Thank you..

Translate
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
People's Champ ,
May 04, 2016 May 04, 2016
LATEST

Two things if you permit:

1) find/change operations can be easily applied to a text frame object:

myTextFrame.changeGrep()…

2) for fixing overrides see this thread:

https://forums.adobe.com/inbox

or here:

Indiscripts :: On Dichotomic Divide-and-Conquer Algorithms

FWIW

Loic

Ozalto | Productivity Oriented - Loïc Aigon

Translate
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