OfficeDev/Word-Add-in-JavaScript-InvoiceManager

Name: Word-Add-in-JavaScript-InvoiceManager

Owner: Office Developer

Description: This Word add-in demonstrates how to load data into custom XML parts bound to content controls in a Word document.

Created: 2015-08-12 01:10:38.0

Updated: 2017-12-23 14:37:18.0

Pushed: 2018-01-31 20:24:56.0

Homepage:

Size: 1599

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Word add-in: Loading data into custom XML parts bound to content controls in a Word document

Table of contents

Summary

In this sample we show you how to use the JavaScript API for Office to write data to a set of custom XML parts that are bound to content controls within a Word document. The following is a picture of the scenario in question.

Screenshot of running sample

We are creating packing slips from customer order data. The packing slip document is shown on the left of the preceding screen shot, with our Office Add-in on the right as a task pane app. When you select an order using the order id drop-down in the task pane on the right and then click the Populate button, the packing slip document is populated with data from that order. The sample uses the Javascript API for Office to interact with the Word document by populating custom XML parts defined in the document with order data. These custom XML parts are bound to content controls that define the UI or the document. To simplify this sample, the order data is stored in the same JavaScript file that creates the add-in. However, in a real application, that data could come from a data source anywhere on the web.

Prerequisites

This sample requires the following:

Key components

This solution was created in Visual Studio. It consists of two projects - InvoiceManager and InvoiceManagerWeb. Here's a list of the key files within those projects.

InvoiceManager project InvoiceManagerWeb project

Description of the code

For a detailed description of this sample, see Exploring the JavaScript API for Office: Data Binding and Custom XML Parts

Build and debug
  1. Open the InvoiceManager.sln file in Visual Studio.
  2. Press F5 to build and deploy the sample add-in and open it in Word.
  3. On the Home ribbon, find the Invoice Manager group and press the Open button.
  4. In the app task pane, select an order in the Order ID drop-down list.
  5. Choose Populate to populate the packing slip in the Word document with information from the selected order.

You can view a list of the custom XML parts in a document by opening the XML Mapping pane in Word (Developer tab).

Troubleshooting

Questions and comments

Contributing

We encourage you to contribute to our samples. For guidelines on how to proceed, see our contribution guide

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Additional resources
Copyright

Copyright (c) 2015 Microsoft. All rights reserved.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.