3 Replies Latest reply on May 26, 2008 4:46 AM by (Dave_Saunders)

    CS3 JS create textFrame with label then change content at a later stage.

    John.Kordas Level 1
      Is it possible to select a textframe by label?

      Here is a simple script which creates 2 text boxes labeled JSLabel and JSLabel2.

      var myDocument = app.documents.add();
      var myTextFrame = myDocument.pages.item(0).textFrames.add();
      myTextFrame.geometricBounds = ["6p", "6p", "24p", "24p"];
      myTextFrame.contents = "Hello World!";
      myTextFrame.label = "JSLabel";

      var myTextFrame = myDocument.pages.item(0).textFrames.add();
      myTextFrame.geometricBounds = ["8p", "8p", "24p", "24p"];
      myTextFrame.contents = "Hello World Again";
      myTextFrame.label = "JSLabel2";

      Here is a script you can run at a later stage to change the content of JSLabel textframe.

      if (app.activeDocument.textFrames[1].label == "JSLabel"){
      var mySelect = app.activeDocument.textFrames[1];
      app.select (mySelect);
      mySelect.contents = "Text has been changed.";
      }

      Rather than using if (app.activeDocument.textFrames[1].label == "JSLabel") can I just select the textframe labeled JSLbel and change the content?