Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

Change Text Preferences

New Here ,
Apr 14, 2010 Apr 14, 2010

Hello

I have a method which changes some text in a text frame But I only wish to change the first instance it finds. At the moment it changes all finds.

Is there a Prefernce setting ChangeTextPreference.ButJustTheFirstOneMatey

or equivalent?

Many Thanks

Mark.

Please ignore the C# and 'pretend' it's javascript.

               private void ChangeTextFrameText(Document doc, TextFrame TargetTextFrame, string ChangeText, string ChangeTo)

                {

                    Application IndesignApp = (Application)doc.Parent;

                    IndesignApp.FindTextPreferences = idNothingEnum.idNothing;

                    IndesignApp.ChangeTextPreferences = idNothingEnum.idNothing;

                    FindTextPreference FTP = (FindTextPreference)IndesignApp.FindTextPreferences;

                    FTP.FindWhat = ChangeText;

                    ChangeTextPreference CTP = (ChangeTextPreference)IndesignApp.ChangeTextPreferences;

                    CTP.ChangeTo = ChangeTo;

                    FindChangeTextOption FCTO = (FindChangeTextOption)IndesignApp.FindChangeTextOptions;

                    FCTO.CaseSensitive = false;

                    FCTO.IncludeFootnotes = false;

                    FCTO.IncludeHiddenLayers = false;

                    FCTO.IncludeLockedLayersForFind = false;

                    FCTO.IncludeLockedStoriesForFind = false;

                    FCTO.IncludeMasterPages = false;

                    FCTO.WholeWord = false;

                    Objects O = TargetTextFrame.ParentStory.ChangeText(false);

                    IndesignApp.FindTextPreferences = idNothingEnum.idNothing;

                    IndesignApp.ChangeTextPreferences = idNothingEnum.idNothing;

          }

TOPICS
Scripting
771
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

Engaged , Apr 14, 2010 Apr 14, 2010

I don't think there is any prefrence like  "ChangeTextPreference.ButJustTheFirstOneMatey"

As per my opinion you replace your code

Objects O = TargetTextFrame.ParentStory.ChangeText(false);

with this

Objects O = TargetTextFrame.ParentStory.FindText();

and you get a list of array in O and then replace O[0] with your output.

Shonky

Translate
Engaged ,
Apr 14, 2010 Apr 14, 2010

I don't think there is any prefrence like  "ChangeTextPreference.ButJustTheFirstOneMatey"

As per my opinion you replace your code

Objects O = TargetTextFrame.ParentStory.ChangeText(false);

with this

Objects O = TargetTextFrame.ParentStory.FindText();

and you get a list of array in O and then replace O[0] with your output.

Shonky

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
New Here ,
Apr 15, 2010 Apr 15, 2010

Thanks mate

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
LEGEND ,
Apr 15, 2010 Apr 15, 2010
LATEST

Of course, changing the contents will totally destroy any anchored objects or tables, etc.

It might be better to use:

var textToChange = TargetTextFrame.ParentStory.findText()[0];

if(textToChange){

  textToChange.changeText();

}

Harbs

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