Welcome to MSDN Blogs Sign in | Join | Help

Microsoft Word 2010

The official blog of the Microsoft Word product team
XML mapping with Word & SharePoint

My name is Amani Ahmed and I'm the program manager whose primary focus is programmability,
which are the tools needed to build applications on top of Word (i.e. macros, add-ins, etc)

In the last post, Travis demonstrated the power of Word to transfer data seamlessly back and forth with a SharePoint library. I'll build on that today by showing how to set up a Word document template to accomplish this. Here's a quick video demo of this process, and I've also stepped through it below.

First, let me show you the SharePoint document library we'll be working with. As you can see, we already have three custom columns set up: Buyer, Seller, and Purchase price. These will be the properties we will map within our documents.

Now let's start our new document template for this site. We'll create a very simple contract to use as our base. As you saw in Travis' demo, the text in the template can be very detailed and complex, but for this example, let's keep things easy and just create a title and a place for the buyer name, seller name, and purchase date. We want the document to look nice, so we'll style the text "Contract" as a title using the Quick Styles gallery on the Home tab. We can now save this as a template to the desktop and name it contract.dotx.

Next, we need to drag the template into a directory that can be seen by the SharePoint site. I've already opened the "Forms" directory for our "Demo2" library and can see the default template. We can drop the new contract template in and close this window.

Let's go back to the site and make sure we use the new template instead of the default. We can change this by going back to our document library and then choosing "Settings" --> "Document Library Settings" from the menu. Now, click "Advanced settings" under the "General Settings" heading.

On the next page, we need to change the template URL from "template.doc" to our "contract.dotx" and hit OK at the bottom of the page.

At this point, we can map the properties to our word template. Go back to Advance settings and click "Edit Template" to open the template in Word.

We are now working with the template that is stored on the site, so when we save any changes, it will be that copy that is automatically updated. In order to map the properties we want, we need to add content controls that map to the columns of our site. We do this through "Insert"à"Quick Parts"à"Document Property" on the Ribbon. As you can see, the "buyer" property is in our list so we'll select that for document. The text "[buyer]" will appear in gray text – this is where the mapped property will be inserted in the document. Let's do the same for the other two properties and save our template.

Finally, we can go back to our site to verify our changes by clicking 'OK' and returning to our library main page. From here, let's try making a new document for our library. Click "New" at the top and Word opens up a new document using our template.

Enter in some data…save the document…and we can see the connection between Word and SharePoint that we set up.

Amani Ahmed

Program Manager | Word | Programmability

Posted: Thursday, January 18, 2007 1:01 AM by wrdblog
Filed under:

Comments

Doug Mahugh said:

Here are a few links to recent news of interest to Open XML developers ... Package Explorer Update. The

# January 18, 2007 3:39 PM

Stefan KZVB said:

I'm still examining the issue with the write-protected files in the start folder of Word 2007. I discovered the following which seems like the same issue:

1) Open the normal.dotm from a location on C: using Word 2007 => it will open without any dialog or write-protection!

2) Change the user template path in Word's options to a network location and copy your normal.dotm there

3) Restart Word 2007

4) Open the normal.dotm from the network location using Word 2007 : You'll get a dialog telling you that normal.dotm is in use by yourself, offering to open it write-protected, open a local copy or get a notification.

Why is Word behaving different when the file is on a network location?

# January 23, 2007 7:51 AM

wes said:

HELP!

Who decided to save the .qat files to the LOCAL SETTINGS folder?  This prevents it from roaming with users who use roaming profiles so our users lose their settings every time they log off and back on (terminal server environment).

How can we address this?

Please let us know!

thanks,

Wes

wes@myf.org

# January 25, 2007 1:18 PM

Matthew Robertson said:

As an avid Office user, I was severely disappointed when the RTM version of Word 2007 had a button to old WordArt. Yes, old WordArt. Dear God. Why this damn this still here? In B2 and B2TR, I thought it was put there temporarily. But in RTM?! (I downloaded the trial.)

What really shocks me is that the new WordArt is implemented. It's in Excel. It's in PowerPoint. But why does Word have old WordArt? (Actually, the new WordArt *is* implemented in Word, but through a loophole. When you create a SmartArt, the SmartArt Tools' 'Format' has new WordArt styles.)

Oh, how I wished my computer illiterate friends would finally replace those horrible old WordArt styles in their documents.

I seriously hope there's an update for this.

(NB. I just don't get it -- it's there; it's there. But then, it's no there. Ran out of time?)

(NB2. This e-mail is not a sledge to the Office 2007 suite as a whole. As a whole its revolutionary. I just wonder why this *feature* is absent from *Word*)

Cheers,

Matthew.

# January 25, 2007 9:24 PM

Derek Daniels said:

This is great for a library of Word documents.  But could this be extended to let me pull data from multiple InfoPath forms into a single Word document?

I would like to combine information from 40+ status reports submitted to a SharePoint via InfoPath into one Word document with full control over the way the document looks.  InfoPath lets me "merge," but I have been unable to get the data formatted the way I need it.  So far I haven't had much luck even accessing this data through code.  Any suggestions?

Thanks!

Derek

# January 26, 2007 7:53 PM

Andrew Goodwin said:

This can be implemented for custom metadata and a few defaults, however 'Version' doesn't seem to be available? Or am I missing something?

Surely one of the more important columns that users may wish to include in a document header. How can this be added??

/Andrew

# January 29, 2007 4:38 AM

in·for·ma·tion /ˌɪnfərˈmeɪʃən/ [in-fer-mey-shuhn] said:

Finally my first blog post - I've been struggling to find something worthwhile to submit and I suppose...

# February 7, 2007 10:09 AM

Simon Thorneycroft and Jonathan Hodgson said:

Part of my role involves me communicating to business units how new technology can improve their processes....

# March 12, 2007 6:34 PM

The Microsoft Office Word Team's Blog said:

Quick Introduction A couple of weeks ago we posted on bibliographies and citation, and it quickly became

# December 14, 2007 12:27 PM

The Microsoft Office Word Team's Blog said:

We saw some questions around columns and text wrapping in Word popping-up in the blogosphere recently,

# June 23, 2008 7:15 PM
New Comments to this post are disabled
Page view tracker