Privacy Policy

Privacy Policy Statement

Your privacy is important to us. This privacy statement explains what personal data we collect from you and how we use it. We encourage you to read the summaries below.

The Office Rich API Demo apps such as Word Rich API Demo, Excel Rich API Demo,  are only for the learning and practicing purpose to help Office developers get familiar with the Office APIs which are released by Microsoft. For details bout Microsoft Privacy Statement, please visit http://www.microsoft.com/privacy.

This Office Rich API Demo apps do not collect any user data or personal information. We do not store any user information or documents in any means.

 

Word Rich API Demo

What is Word Rich API?

Word Rich API is a new version of JavaScript API that can be used in Word Add-ins to manipulate the documents. The interface of the APIs is consistent across the different platforms. Details can be found at Microsoft MSDN.

How to Play with the Word Rich API?

The Word Rich API Demo app helps you to learn and play with the new set of Word Rich APIs. You can open a document from Word or Word Online, and insert this demo app as a Taskpane Add-in. You can do this by click the Insert menu item, then click the My Add-ins icon in the ribbon bar, and choose this app from Office STORE and insert it into your document, and the add-in will be displayed together with your document.

In the upper Code text box, enter your code or copy/paste from the Microsoft MSDN, and then click Execute. If you want to show the output in the lower Output box, please call writeLog() method to show the logs or results. If you are running the add-in in Word Online, then you can also call console.log() to output to the browser debug console. You need to open the console to see the output.

Word Rich API Sample Code

Below are the samples that use the Word Rich APIs. These samples can help you to get familiar with the syntax and styles of these Word APIs. You can copy the sample code and paste it into the text box at the demo app, and click Execute to run it.

Sample Code: Insert Text


// Run a batch operation against the Word object model.
Word.run(function (context) {
    
    // Create a proxy object for the document body.
    var body = context.document.body;
    
    // Queue a commmand to insert text in to the beginning of the body.
    body.insertText('This is text inserted with body.insertText()', Word.InsertLocation.start);
    
    // Synchronize the document state by executing the queued commands, 
    // and return a promise to indicate task completion.
    return context.sync().then(function () {
        writeLog('Text added to the beginning of the document body.');
    });  
})
.catch(function (error) {
    console.log('Error: ' + JSON.stringify(error));
    if (error instanceof OfficeExtension.Error) {
        writeLog('Debug info: ', JSON.stringify(error.debugInfo));
    }
});