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

Get FrameMaker Text as a String

Community Expert ,
Mar 15, 2024 Mar 15, 2024

Copy link to clipboard

Copied

How do I get FrameMaker text into a string using ExtendScript?

TOPICS
Scripting

Views

159

Translate

Translate

Report

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

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 = 
...

Votes

Translate

Translate
Community Expert ,
Mar 15, 2024 Mar 15, 2024

Copy link to clipboard

Copied

LATEST
#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;
}

Votes

Translate

Translate

Report

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