2 Replies Latest reply on Nov 17, 2015 9:41 AM by ricat03

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

    ricat03

      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

              }

      }