How to clear and set a new string to a textframe ?

Community Beginner ,
Jan 17, 2018

Copy link to clipboard

Copied

Hello forum.

A simple question that seems to be easy .

How to clear  a textframe and set à new string in it.

assuming this code :

if (textFrame.ObjectValid()) {

      if (textFrame.constructor.name === "TextFrame") {

         // how to clear the text inside the textframe

          // how to set the new string " new text in the textframe"

      }

    }

this text frame in on a reference page inside an unanchoredframe but i know how to get there.

thank you for your help

Orveo

TOPICS
Scripting

Views

252

Likes

Translate

Translate

Report

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

1 Correct Answer

Adobe Community Professional , Jan 18, 2018
frameexpert Adobe Community Professional , Jan 18, 2018
This will work with a selected text frame:#target framemakervar doc = app.ActiveDoc;var textFrame = doc.FirstSelectedGraphicInDoc;// Delete the first paragraph in the text frame.textFrame.FirstPgf.Delete ();// Add the new text.var textLoc = new TextLoc (textFrame.FirstPgf, 0);doc.AddText (textLoc, "The new text I want to add.");Since you already have a TextFrame object (the textFrame variable) in your code, just use lines 5-9. Note that on line 9, you do need a Doc object for the AddText method....

Likes

Translate

Translate
Jump to answer Jump to answer
Adobe Community Professional ,
Jan 17, 2018

Copy link to clipboard

Copied

Is your text frame connected to other text frames or just a separate text frame?

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Jan 18, 2018

Copy link to clipboard

Copied

in the unanchored frame on the reference page there (is) are graphic frame(s) and only one textframe.

this textframe is like a title.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Jan 18, 2018

Copy link to clipboard

Copied

This will work with a selected text frame:

#target framemaker

var doc = app.ActiveDoc;

var textFrame = doc.FirstSelectedGraphicInDoc;

// Delete the first paragraph in the text frame.

textFrame.FirstPgf.Delete ();

// Add the new text.

var textLoc = new TextLoc (textFrame.FirstPgf, 0);

doc.AddText (textLoc, "The new text I want to add.");

Since you already have a TextFrame object (the textFrame variable) in your code, just use lines 5-9. Note that on line 9, you do need a Doc object for the AddText method.

Rick

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
laurentd2522238 AUTHOR LATEST
Community Beginner ,
Jan 23, 2018

Copy link to clipboard

Copied

Ok thank you for you answer.It works fine.

Orveo

Likes

Translate

Translate

Report

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