Skip to main content
K.Daube
Community Expert
Community Expert
April 16, 2015
Answered

Copy paragraph to another doc

  • April 16, 2015
  • 1 reply
  • 882 views

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.

Klaus

This topic has been closed for replies.
Correct answer Klaus Göbel

Hi Klaus,

have a look at line 20

I think that doesn't work. Try "tRange.end.offset = Constants.FV_OBJ_END_OFFSET"  instead

1 reply

Klaus Göbel
Klaus GöbelCorrect answer
Legend
April 16, 2015

Hi Klaus,

have a look at line 20

I think that doesn't work. Try "tRange.end.offset = Constants.FV_OBJ_END_OFFSET"  instead

K.Daube
Community Expert
K.DaubeCommunity ExpertAuthor
Community Expert
April 17, 2015

Thanks Klaus: A great step forward (not for mankind, but for me!).