Snippets - Word


Snippet Explorer

https://officesnippetexplorer.azurewebsites.net/#/snippets/word
https://github.com/OfficeDev/office-js-snippet-explorer



Inserting formatted text, html, ooxml (Office Open XML) on the current selection
Formatting an existing paragraph, font, size, color, highlight color, style, etc.
Changing paragraph properties (i.e. alignment, indentation, etc)
Inserting Paragraphs
Append/Prepend text to paragraphs
Traversing the document's or section's paragraphs
Wrapping a paragraph with a content control
Getting a collection of content controls by tag or title (or all)
Setting Content Control Properties
Clear document body content
Insert content on the header/footer of the document
Insert an inline picture
Search, plain text and using wild cards



Writing Text

Write text to the current user selection

Office.context.document.setSelectedDataAsync("Hello World!", 
                                              function (asyncResult) {
  if (asyncResult.status == "failed") {
    showMessage("Action failed with error: " + asyncResult.error.message);
  }
});

Reading Text

Read text from the user current selection

Office.context.document.getSelectedDataAsync("text", 
                                             function (asyncResult) {
  if (asyncResult.status == "failed") {
    showMessage("Action failed with error: " + asyncResult.error.message);
  }
  else {
    showMessage("Selected data: " + asyncResult.value);
  }
});



© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited TopPrev