Search code examples
ms-wordoffice-jsoffice-addinsword-addinsword-web-addins

How to create Word office with name from createDocument(base64File) API or any another methods/API?


I am doing below for word document :-

Step 1. Open document from base64 . Please check below link . Document is open with random name like Document1, Document 2

https://learn.microsoft.com/en-us/javascript/api/word/word.application?view=word-js-preview#word-word-application-createdocument-member(1)

  await Word.run(async (context) => {
        var newDoc = context.application.createDocument(base64);
        context.load(newDoc);
        //Want to give document name like newDoc.name ="sample documents"
        return context.sync().then(function () {
            newDoc.open();
        });

      });

Step-2 We are passing base 64 from our Rest API so want to open document with new name and also pass some custom data to new documents .


Solution

  • OfficeJS doesn't provide anything for that out of the box.

    Feature requests on Tech Community are considered, when the dev team go through the planning process. Use the github label: Type: product feature request at https://aka.ms/M365dev-suggestions .