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

Copy paragraph to another doc

Community Expert ,
Apr 16, 2015 Apr 16, 2015

Copy link to clipboard

Copied

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

TOPICS
Scripting

Views

758

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

Enthusiast , Apr 16, 2015 Apr 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

Votes

Translate

Translate
Enthusiast ,
Apr 16, 2015 Apr 16, 2015

Copy link to clipboard

Copied

Hi Klaus,

have a look at line 20

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

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
Community Expert ,
Apr 17, 2015 Apr 17, 2015

Copy link to clipboard

Copied

LATEST

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

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