1
Community Expert
,
/t5/framemaker-discussions/get-framemaker-text-as-a-string/td-p/14491503
Mar 15, 2024
Mar 15, 2024
Copy link to clipboard
Copied
How do I get FrameMaker text into a string using ExtendScript?
TOPICS
Scripting
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
Community Expert
,
Mar 15, 2024
Mar 15, 2024
#target framemaker
var doc, textRange, text;
// Make variables for the active document and the current text selection.
doc = app.ActiveDoc;
textRange = doc.TextSelection; // TextRange object
text = getText (textRange, doc);
alert (text);
function getText (textObj, doc) {
// Gets the text from the text object.
var textItems, text, count, i;
// Get a list of the strings in the text object or text range.
if (textObj.constructor.name !== "TextRange") {
textItems =
...
Community Expert
,
LATEST
/t5/framemaker-discussions/get-framemaker-text-as-a-string/m-p/14491504#M83198
Mar 15, 2024
Mar 15, 2024
Copy link to clipboard
Copied
#target framemaker
var doc, textRange, text;
// Make variables for the active document and the current text selection.
doc = app.ActiveDoc;
textRange = doc.TextSelection; // TextRange object
text = getText (textRange, doc);
alert (text);
function getText (textObj, doc) {
// Gets the text from the text object.
var textItems, text, count, i;
// Get a list of the strings in the text object or text range.
if (textObj.constructor.name !== "TextRange") {
textItems = textObj.GetText (Constants.FTI_String);
}
else {
textItems = doc.GetTextForRange (textObj, Constants.FTI_String);
}
// Concatenate the strings.
text = "";
count = textItems.length;
for (i = 0; i < count; i += 1) {
text += (textItems[i].sdata);
}
return text;
}
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

