I found this at least myself https://learn.microsoft.com/en-us/office/client-developer/office-uri-schemes
How to open existing document with Office JS API
Is there a way to open existing document with Office JS API (Word, Excel, PowerPoint) as we can open new document with stream? If there is no API support, is there protocol URLs which we could use (in desktop/browser win/mac) to accomplish this?
Our use case is that we automate document saving process so that document is stored to predefined location. After this is done, we need to open this copy for user.
Microsoft 365 and Office Development Office JavaScript API
Microsoft 365 and Office Development Other
3 answers
Sort by: Most helpful
-
-
Goetting, Dennis 0 Reputation points
2023-01-29T21:34:45.4833333+00:00 Hi,
apparently there has been an update recently, which based on some code examples seen allows to open a document using the office JS API. See also the MIcrosoft documentation
createDocument(base64File)
Creates a new document by using an optional base64 encoded .docx file.
TypeScriptCopy
createDocument(base64File?: string): Word.DocumentCreated;
function onaddOpenDoc() { Word.run(function (context) { // this getDocumentAsBase64 assumes a valid base64-encoded docx file var myNewDoc = context.application.createDocument(getDocumentAsBase64()); context.load(myNewDoc); return context.sync() .then(function () { myNewDoc.open(); context.sync(); }).catch(function (myError) { //otherwise we handle the exception here! showNotification("Error", myError.message); }) }).catch(function (myError) { showNotification("Error", myError.message); }); } createDocument
-
peiye zhu 165 Reputation points
2023-08-27T23:30:42.5366667+00:00