Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Function to get ooxmldocument via XMLHttpRequest
- function getTemplate(fileName) {
- var myOOXMLRequest = new XMLHttpRequest();
- var myXML;
- myOOXMLRequest.open('GET', fileName, false);
- myOOXMLRequest.send();
- if (myOOXMLRequest.status === 200) {
- myXML = myOOXMLRequest.responseText;
- console.log('myXML VariabelData: ', myXML);
- return myXML;
- }
- return "" ;
- }
- // Insert a 'default' template with logo and contentControllers in header and footer of the xml
- function insertDefaultTemplate() {
- Word.run(function (context) {
- var body = context.document.body;
- // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion.
- return context.sync().then(function () {
- var t = getTemplate('/Content/Templates/BrevmallMD.xml', 'Replace');
- body.insertText("Formaterar dokument...", Word.InsertLocation.start);
- return context.sync().then(function () {
- body.insertOoxml(t, Word.InsertLocation.replace);
- return context.sync().then(function () {
- showNotification("Standardmallen är införd!", "Välj användaruppgifter.");
- });
- });
- })
- }).catch(function (error) {
- errorHandler();
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement