Highlighted

Framemaker doesn't show where text or objects are selected via Extendscript

New Here ,
Nov 17, 2015

Copy link to clipboard

Copied

I have some Extendscript that opens a document, locates a graphic, and selects it. The image is selected, as evident by the image details showing in Object Properties. Problem is, Framemaker doesn't scroll the window to show the selection.

So far, the only way I've been able to get Framemaker to jump to the right location is by selecting the text around the graphic, then using my keyboard I press the arrow keys to jump to the location. Then I manually select the graphic. This worked for our needs at first, but now for other scripts I really need to be able to have the image selected and visible on screen.

I even tried selecting the text around it, using fcodes to simulate the keyboard arrow keys, and then selecting the graphic, but Framemaker still didn't update what part of the document it was showing on screen.

This is my current function. Any thoughts?

//imageID is the unique ID of the frame the image is in, docName is the path & file name for the document containing the image

function findSelectedGraphic (imageID, docName) {

   

        var begOffset = 0;

        var endOffset = 0;

        var textRange;

       

        var newdoc = OpenFile(docName);

        var selectedGraph = newdoc.GetUniqueObject(Constants.FO_AFrame, imageID);

       

        if (selectedGraph.ObjectValid()) {

            var vFramePgf;

            vFramePgf = selectedGraph.TextLoc.obj;

           

            var newTextLoc = new TextLoc (vFramePgf, selectedGraph.TextLoc.offset + 1);

            textRange = new TextRange(newTextLoc, newTextLoc); 

            newdoc.TextSelection = textRange;

            var fcodes = new Array();

            fcodes[0] = FCodes.KBD_MOVE_LEFT;

            Fcodes(fcodes);

            selectedGraph.FirstGraphicInFrame.GraphicIsSelected = 1

        }

}

Hi ricat03,

just try  "ScrollToText"

myDoc.ScrollToText (textRange);

That should work.

TOPICS
Scripting

Views

652

Likes

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

Framemaker doesn't show where text or objects are selected via Extendscript

New Here ,
Nov 17, 2015

Copy link to clipboard

Copied

I have some Extendscript that opens a document, locates a graphic, and selects it. The image is selected, as evident by the image details showing in Object Properties. Problem is, Framemaker doesn't scroll the window to show the selection.

So far, the only way I've been able to get Framemaker to jump to the right location is by selecting the text around the graphic, then using my keyboard I press the arrow keys to jump to the location. Then I manually select the graphic. This worked for our needs at first, but now for other scripts I really need to be able to have the image selected and visible on screen.

I even tried selecting the text around it, using fcodes to simulate the keyboard arrow keys, and then selecting the graphic, but Framemaker still didn't update what part of the document it was showing on screen.

This is my current function. Any thoughts?

//imageID is the unique ID of the frame the image is in, docName is the path & file name for the document containing the image

function findSelectedGraphic (imageID, docName) {

   

        var begOffset = 0;

        var endOffset = 0;

        var textRange;

       

        var newdoc = OpenFile(docName);

        var selectedGraph = newdoc.GetUniqueObject(Constants.FO_AFrame, imageID);

       

        if (selectedGraph.ObjectValid()) {

            var vFramePgf;

            vFramePgf = selectedGraph.TextLoc.obj;

           

            var newTextLoc = new TextLoc (vFramePgf, selectedGraph.TextLoc.offset + 1);

            textRange = new TextRange(newTextLoc, newTextLoc); 

            newdoc.TextSelection = textRange;

            var fcodes = new Array();

            fcodes[0] = FCodes.KBD_MOVE_LEFT;

            Fcodes(fcodes);

            selectedGraph.FirstGraphicInFrame.GraphicIsSelected = 1

        }

}

Hi ricat03,

just try  "ScrollToText"

myDoc.ScrollToText (textRange);

That should work.

TOPICS
Scripting

Views

653

Likes

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
Nov 17, 2015 0
Enthusiast ,
Nov 17, 2015

Copy link to clipboard

Copied

Hi ricat03,

just try  "ScrollToText"

myDoc.ScrollToText (textRange);

That should work.

Likes

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
Reply
Loading...
Nov 17, 2015 0
ricat03 LATEST
New Here ,
Nov 17, 2015

Copy link to clipboard

Copied

Thanks so much! That worked perfectly.

Likes

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
Reply
Loading...
Nov 17, 2015 0