2 Replies Latest reply on Apr 17, 2015 12:25 AM by K.Daube

    Copy paragraph to another doc

    K.Daube Level 2

      Dear friends,

      Again I'm stuck in the jungle of objects and properties...

      I want to push a pargraph (containing character formats) in an array to be able to get it out later (in another document) for pasting it there (probably multiple times). So I started with the simple case: get 1 para and look whether it is in the clipboard:

      var gaBibliography= [];                           // bibliography lines from processed RTF
      // have the file with the formatted bibliography already open, and the bibliography starts in the first paragraph
      GetBiblioFromRTF ();
      function GetBiblioFromRTF () {                    // very rudimentary start ...
        var newDoc, pgf, pgf1, tRange, index;
        newDoc = app.ActiveDoc;
        pgf = newDoc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;  // get first pgf in flow
        gaBibliography.push(pgf);                        // for use in other docs/book
      // simulate later use in own function
        tRange = new TextRange;
        index = gaBibliography.length-1;
      //alert (gaBibliography[index]);                  // => object pgf
        pgf1 = gaBibliography[index];
        tRange.beg.obj = pgf1;                          // select it
        tRange.beg.offset = 0;
        tRange.end.obj = pgf1;
        tRange.end.offset = pgf1;
        newDoc.TextSelection = tRange; 
        newDoc.Copy (0);                                // "gaBibliography[index]" only ! no para contens

      Although the alert reports gaBibliography[index] to be object pgf the clipboard just contains stuff from previous copy opertions (most time this is just text, no formatted text).

      A PushClipboard() before the Copy doesn't do anything useful.


      I'm again tangled in lianas.