Closed
Description
Host: Word
Office version number: Latest
Operating System: macOS
Browser: Google Chrome
I’m developing a Word add-in using Office.js and encountered an issue with the createDocument() method. My code works as expected in the desktop version of Word, where it successfully creates and opens a new document. However, in Word Online, instead of opening a new document, I only see the popup message:
"This add-in is about to create a new document in your default folder on your current cloud repository."
After that, no new document appears, and nothing seems to happen. Here is the relevant code snippet:
export const createNewDocument = async (): Promise<void> => {
try {
await Word.run(async (context) => {
const newDoc: Word.DocumentCreated = context.application.createDocument();
newDoc.open();
});
} catch (error) {
console.error("Error creating document:", error);
}
};
My questions are:
- Is context.application.createDocument() officially supported in Word Online?
- If it is supported, is there a workaround to ensure that the newly created document actually opens?
- If it’s not supported, is there an alternative method for creating and opening a new document in Word Online?