Follow us on Twitter
Follow us in Facebook
Office Dev Content
SharePoint Dev Content
Blogs for Office developers > Office and Office 365 dev blog
In this post, I’ll highlight some of the new features for developers in Word 2013 Preview.
As Frank Rice mentioned in his recent post, What’s new in Office 2013 Preview for developers, the most exciting new feature in Office 2013 Preview is apps for Office, which, for example, enables you to use live web content directly in a Word document.
To develop your own app for Office, you can use popular languages such as Python, PHP, Perl, or, JavaScript, as well as HTML5; and web development tools, such as Microsoft Visual Studio 2012. One example app―shown in the following figure—provides definitions of words selected in the Word document window.
When you create apps for Office 2013 Preview, you can make them publically available in the Office Store. There, they can be purchased or made available for free, depending on your preference. Organizations can create an internal store, known as the App Catalog. The App Catalog provides a central location for all solutions, whether developed internally or externally. This enables the IT department to manage and monitor solutions centrally.
To find out more about apps for Office and download samples, check out the new Office for developers site on MSDN, and the apps for Office blog.
Word 2013 Preview adds some great new content-control-related features, such as repeating content controls, color coding, and control over the appearance of the content control in the document. In case you’re not familiar with content controls, they are regions in a document that serve as containers for specific types of content, as shown in the figure below. Content controls can contain content such as dates, lists, or paragraphs of formatted text. Incidentally, the apps for Office that you create can interact with content controls, including repeating content controls, by means of custom XML parts.
The following VBA code sample shows one way that you can use repeating content controls programmatically. It sets up a table row that has three XML mappings and uses a repeating content control to repeat that row for each <book> element in a custom XML part in the document.
Sub testRepeatingControl() Dim objRange As Range Dim objTable As Table Dim objCustomPart As CustomXMLPart Dim objCC As ContentControl Dim objCustomNode As CustomXMLNode Set objCustomPart = ActiveDocument.CustomXMLParts.Add objCustomPart.LoadXML ("<books>" & _ "<book><title>Code</title>" & _ "<author>Charles Petzold</author></book>" & _ "<book><title>JavaScript Step by Step</title>" & _ "<author>Steve Suehring</author></book>" & _ "<book><title>Understanding IPv6</title>" & _ "<author>Joseph Davies</author></book></books>") Set objRange = ActiveDocument.Paragraphs(1).Range Set objTable = ActiveDocument.Tables.Add(objRange, 2, 2) Set objRange = objTable.Cell(1, 1).Range Set objCustomNode = objCustomPart.SelectSingleNode("/books[1]/book[1]/title[1]") Set objCC = ActiveDocument.ContentControls.Add(wdContentControlText, objRange) objCC.XMLMapping.SetMappingByNode objCustomNode Set objRange = objTable.Cell(1, 2).Range Set objCustomNode = objCustomPart.SelectSingleNode("/books[1]/book[1]/author[1]") Set objCC = ActiveDocument.ContentControls.Add(wdContentControlText, objRange) objCC.XMLMapping.SetMappingByNode objCustomNode Set objRange = objTable.Rows(1).Range Set objCC = ActiveDocument.ContentControls.Add(wdContentControlRepeatingSection, objRange) objCC.XMLMapping.SetMapping ("/books[1]/book") End Sub
Other developer features in Word 2013 Preview include: