OfficeDev/Word-Add-in-JavaScript-ChangeContentWithXML

Name: Word-Add-in-JavaScript-ChangeContentWithXML

Owner: Office Developer

Description: The sample Word Add-in shows how to use JavaScript to extract Open XML from a potentially complex document. The sample also shows how to insert a fragment of Open XML into a document.

Created: 2015-08-12 23:19:58.0

Updated: 2017-01-09 20:57:11.0

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

Homepage:

Size: 1252

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Word-Add-in-JavaScript-ChangeContentWithXML

Table of contents

Summary

The sample Word Add-in shows how to use JavaScript to extract Open XML from a potentially complex document. The sample also shows how to insert a selected fragment of Open XML into a document.

The sample comes with a test document ComplexDoc.docx, which is set as the StartAction property of the task pane add-in. The document contains a mixture of images with various layout options and text. Make sure the document loads when you start debugging, and if not, check the StartAction property of the project.

Note The sample uses Open XML instead of HTML or plain text, because only Open XML is capable of handling the Base64 data that represents the images in the document. Also, Open XML is potentially more powerful at describing text flows with images.

Prerequisites

This sample requires:

Key components of the sample

The sample solution contains the following files:

The sample add-in contains the ChangeContentWithXML project, which contains:

It also contains the ChangeContentWithXMLWeb project, which includes:

Build and debug
  1. Open the ChangeContentWithXML.sln file with Visual Studio. No other configuration is necessary.
  2. To build the sample, choose the Ctrl+Shift+B keys.
  3. To run the add-in, choose the F5 key.
  4. On the Home tab, click the Open button in the XML Content group.

Note It is recommended that you select all the content between the two instructions as shown the first time you run the sample, so that you can see the full power of Open XML. You can experiment with selecting smaller sections after that.

Troubleshooting

If the add-in starts with a blank document instead of the test document, ensure the Start Document property of the project is set to ComplexDoc.docx and not just to [New Word document].

To do this, select the ChangeContentWithXML project in the Solution Explorer and view the properties in the Properties window. Under App you will see Start Action and Start Document listed. The values for these should be:

Questions and comments

Additional resources
Copyright

Copyright (c) 2015 Microsoft. All rights reserved.

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.


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.