xxxxxxxxxx
Word.run(function(context) {
// this will return the full paragraphs within the selection:
var myParagraphs = context.document.getSelection().paragraphs;
context.load(myParagraphs);
return context.sync()
.then(function(){
for(var i=0; i< myParagraphs.items.length; i++){
// here you will get the full paragraphs, not just what the user selected.
console.log("this is full paragraph:" + (i + 1) + ":" + myParagraphs.items[i].text);
}
})
});
xxxxxxxxxx
Word.run(function (context) {
var pars = context.document.getSelection().paragraphs;
pars.load();
return context.sync().then(function () {
pars.items[0].getRange().expandTo(pars.items[pars.items.length - 1].getRange()).select();
return context.sync()
}).catch(function (error) {
console.log(error.message);
});
})