In my current project, I am developing a Microsoft Word add-in using TypeScript, React, and the Word API. One of the key features of this add-in will allow users to open a document located on their computer, such as "C:\Test\Test.docx", with just a click of a button situated in the task pane of the add-in.
By leveraging the Word's API, I believe it is possible to open an existing document by first converting it or its filepath to a base64 string. This base64 string can then be utilized with the method "createDocument(base64File)". For more information on this topic, you can visit this link.
However, the challenge lies in obtaining this base64 string. My research so far has mainly pointed towards uploading documents to generate a base64 string, which might not necessarily be required for opening an already existing document.
Unfortunately, I do not have any specific code snippets to showcase at the moment.
const openWordDocument = (): void => {
Word.run(async (context) => {
context.application.createDocument().open();
});
};