Feedback by UserVoice

I suggest you ...

API to point to next and previous paragraph from the current paragraph

It would be very useful for processing large document to have the ability to access previous and next paragraph from any paragraph object.
Thanks

6 votes
Vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Petr Simon shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

2 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...
  • Petr Simon commented  ·   ·  Flag as inappropriate

    Finally had a chance to test it. Thank you again. Just in case someone runs into this thread, this is how I do it.

    Word.run(function (context) {
    var range = context.document.getSelection();
    context.load(range.paragraphs);
    return context.sync()
    .then(function () {
    var para = range.paragraphs.items[0];
    for (var i = 0; i < totalBefore; i++) {
    para = para.getPrevious();
    loadedParagraphs.splice(0, 0, para);
    }

    para = range.paragraphs.items[0];
    for (var i = 0; i < totalAfter; i++) {
    para = para.getNext();
    loadedParagraphs.push(para);
    }

    loadedParagraphs.forEach(function (p) {
    context.load(p);
    });

    loadedParagraphs.splice(totalBefore, 0, range.paragraphs.items[0]);
    })
    .then(context.sync)
    .then(processParagraphs)
    .then(context.sync)
    })

Feedback and Knowledge Base