Developers have long been able to leverage Word’s programmability model to extend the functionality of Word and deliver amazing results. Today we’re going to highlight 5 new features that makes the Word 2013 better than ever for developers.
1. Apps for Word – embracing the cloud
Apps can also read in your entire document for full fidelity printing, faxing, or other export scenarios. In addition, they can leverage the power of custom XML parts and data bindings to accomplish a variety of scenarios. For example, an XML file of recent expenses could be used to dynamically generate custom invoices. You can take a look at this sample app to learn more about how to use custom XML parts with Word apps.
To get started developing apps for Office check out Apps for Office and SharePoint blog and dev.office.com. They are great resources that can help you learn more about the Office API and feature code samples to make it easy.
2. Content control improvements
For several releases, we’ve been working to make Word a great structured document editor. We created content controls in Office 2007, and built on that foundation in Office 2010. In Office 2013, we’ve again improved our existing content control support to make them easier to use.
As the types of Word documents containing content controls have increased, we recognized the need to make content controls more flexible. We wanted to make sure that documents with several content controls (including many levels of nesting) could visually scale to what the author requires.
To that end, Word 2013 now supports improved content control visualizations – we give document authors the ability to:
- Choose a visualization style for each control
- Update the color of controls
For visualization styles, we now let users customize whether the controls appear in a bounding box (as they did in Office 2010), appear as start/end tags (useful when many controls are nested), or are invisible (useful for when users don’t need to know about underlying structure). Here is a screenshot showing these options:
You can set both the visual style and the color of the content control UI in the content control properties dialog (accessible from the Properties button on the Developer tab). The dialog for a rich text control is shown here:
3. Binding to rich text content controls
You asked, we delivered – we heard loud and clear that developers would like the ability to bind rich text controls to custom XML parts (leaf nodes or attributes). You can bind these controls like you would bind other controls, or you can use the new XML mapping pane to create the binding (see below in this post).
When the mapping is active, the associated custom XML node contains a serialized XML representation of the content in the control. This serialization is created as follows:
- Word retrieves the flat XML representation of the content in the control (just as the .WordOpenXML property does in the object model today)
- Word escapes the resulting string to remove reserved XML characters
- Word stores the result as text in the mapped node
4. Repeating content controls
Another very common request for structured documents is the ability for document authors to allow users to map to tabular, structured data. For example, in a structured expense report, allowing users to add expense line item rows to a table containing each expense.
To support these requests, we’ve created a new content control type: the repeating section content control. This control can be added around a row (or rows) of a table, or around arbitrary paragraphs of content. Once added, users can add new rows to the control, and if the control is bound the content in these rows will be stored appropriately in the document’s custom XML.
It’s also possible to bind a repeating section content control to the custom XML of a document. The control itself can be mapped to a nodeset, and then each repeating item inside of the control will be mapped to a node in that set. For example:
5. XML mapping pane
Finally, we also heard the feedback that it’s too hard to set up XML mappings to content controls in Word – to make this easier, Word 2013 includes a built-in XML Mapping task pane (available from the Developer tab) that allows you to add custom XML parts and map their contents to content controls in the document.
For example, if I have some XML like the following:
I can add it to a Word document and create XML mappings by simply:
- Opening the task pane
- Dropping the list of Custom XML Parts and choosing Add New Part…
- Choosing the item I want to map, right-clicking, and selecting Insert Content Control, which gives me a list of valid content controls that this content can be mapped to:
Selecting it inserts a new content control and creates the XML mapping, setting everything up in a single step.
Putting it all together
We’re really excited about the new and existing scenarios these new features will help developers enable. We also know that developers rely on classic extensibility models like VBA, VSTO solutions, and COM add-ins. Those continue to be supported in Word 2013! You’ll also find our new features like videos, expand/collapse, etc. are exposed in Word’s Object Model. This allows your existing solutions to continue to run in Word 2013 and allows you to incorporate new features if desired.
With the features described above, we give you the tools to deliver your customers excellent customized experiences. And with Apps for Office, we’ve also allowed you to go one step further by choosing the business model that’s right for you to reach the broadest set of customers. Your app can be free, trial based, ad supported, etc. Once you’ve decided on how to reach customers you can publish your app using the office store. Customers can easily acquire your apps by searching directly from within Word or opening documents and templates that already contain your app. Don’t forget to check out http://officeappcontest.com to learn how you can win prizes by developing apps.
Thanks for reading. We hope you love the additional developer-oriented capabilities of Word 2013..