SharePoint Events

  7/22 - Webcast: Enterprise Document Security, Tracking and Collaboration in SharePoint
  7/24 - Webcast: Enhance Collaboration and Mitigate Risk with Email and Document Management in SharePoint
  7/29 - Webcast: Regulatory and Corporate Risk Protection in SharePoint for Financial Services
  7/31 - Webcast: Workflow throughout the Enterprise for Legal Firms and Departments

 SharePoint Videos

  Why SharePoint 2013
  Keys to Successful SharePoint Initiatives and User Adoption
  Out of the Box Business Intelligence and Reporting in SharePoint 2013
  Driving the Business Case and User Adoption for SharePoint
  Automate Business Processes with SharePoint 2013 and Business Connectivity Services
  SharePoint and Office 365 Migration Made Easy
  Full Lifecycle Content Management with SharePoint 2013
  Compliant Document Generation and Assembly in SharePoint
  Application of Content Security and Corporate Risk Protection in SharePoint
  How to Redline, Markup, Collaborate and Review Content in SharePoint
  Advanced Content Lifecycle and Records Management in SharePoint
  Advanced Workflow Made Easy with SharePoint 2013 and Nintex
  Full Lifecycle Content Management with SharePoint 2013
  SharePoint 2013 Solutions for the Financial Services Industry
  ProjectReady 2013: SharePoint Solutions built for the AEC
  SharePoint 2013 Solutions for the Legal Industry
  Driving the Business Case and User Adoption for SharePoint
  Investment Considerations for SharePoint 2010 and SharePoint 2013
  SharePoint 2013 and Enterprise Content Management
  SharePoint 2013 Launch
(More Links...)

 Archives

Opening SharePoint Links in a new windowUse SHIFT+ENTER to open the menu (new window).
Mail Enabled Lists vs. The Missing Windows 2008 POP3/IMAP Server Use SHIFT+ENTER to open the menu (new window).
7 Tools for SharePoint DevelopersUse SHIFT+ENTER to open the menu (new window).
Public Facing Masterpage TechniquesUse SHIFT+ENTER to open the menu (new window).
How to Quickly Deploy and Activate a Timer Service to Your Site CollectionUse SHIFT+ENTER to open the menu (new window).
Custom SharePoint Master Page Feature with WSP BuilderUse SHIFT+ENTER to open the menu (new window).
Date Math with InfoPathUse SHIFT+ENTER to open the menu (new window).
Enterprise Search Tricks and Tips Part 1Use SHIFT+ENTER to open the menu (new window).
Populating Word Documents With SharePoint Data. Try The DIP!Use SHIFT+ENTER to open the menu (new window).
Programmatic Deep Dive into Blank SharePoint Lookup ColumnsUse SHIFT+ENTER to open the menu (new window).
1 - 10 Next
Populating Word Documents With SharePoint Data. Try The DIP!

By: Omar Stewart

Before beginning the actual walkthrough, let’s take a look at the goal of the demonstration. We have a SharePoint list with some basic data. We want users to be able to open a new Word document (based on our template) and have it populate with data from that list.

Requirements:

· SharePoint 2007

· Word 2007

· InfoPath 2007 (Also required on client machine)

For our example, we have a standard SharePoint list which contains employee names, their most recently played game, and their Gamer Score.

clip_image001

Let’s begin by creating our custom content type. Head on over to Site Actions >> Site Settings >> Modify All Site Settings >> Galleries : Content Types >> Create.

clip_image002

We'll call our Content type "Gamer Score Card", the parent type will be "Document". We'll give our Score Cards a brief description, and place it in a new group called "Gaming".

clip_image004

Now that we have our Score Card Content Type, we can add columns that will be relevant to our scorecard. Click "Add from new site column" to add the following columns:

· "Recently Played Game" - Single line of text

· "Gamer Score" - Single line of text

clip_image006

We now have our Content Type in position, so we need to create a Document Library to house our newly created Score Cards. Create a new Document library called "Gamer Score Cards". We now have to let our Document Library know that we want it allow management of the Gamer Score Card Content Type.

From the document library, click Settings >> Document Library Settings.

clip_image008

Click Advanced Settings >> Enable the management of content types.

clip_image010

Back in the document library settings, we can now see the Content Type Section. First we need to add our Gamer Score Card Content Type to the Library. Click "Add from existing site content types"

clip_image012

Select the "Gaming" Group from the drop down. Click the "Gamer Score Card", then click Add.

Since we will only keep Gamer Score Cards in this document library, we can set it to our default content type. Click "Change new button order and default content type". We want to uncheck the Document Content Type, leaving only Gamer Score Card Checked.

clip_image014

If we go back to our Gamer Score Cards document library and click New, we should see a new word document appear. Now that we have our Gamer Score Card Content Types and A Document Library for them, it’s time to actually start designing our Score Card. Open MS Word and Design a template for your score card. You can design it to your liking, here’s a quick one I whipped up. You can download my template (here).

clip_image016

Save your file as a Word Document Template (.dotx)

Now that we've created a template for our Gamer Score Card, we can assign it to our Gamer Score Card Content Type. Go back to the Settings for our Gamer Score Card Content Type (Site Actions >> Modify All Site Settings >> Galleries: Site Content Types >> Gaming: Gamer Score Card.

Click Advanced Settings, and Browse to upload our new document template.

clip_image018

Now, navigate back to the Gamer Score Cards Document Library and click New. You should see a new instance of the gamer score card, using the template we just created.

You should also see the DIP (Document Information Panel) Appear. The DIP should also contain our three custom column names. (*If the DIP is not visible, click the Office button >> Prepare >> Properties.)

clip_image020

We now need to map the fields in the DIP, to text fields in word.

Click in the area next to "Name: " and from the word ribbon, click Insert >> Quick Parts >> Document Property.

You will be presented with a list of properties associated with this document template that we can drop into word including the columns that we associated with our content type.

clip_image022

· Select, Title to insert a title field which will represent the Name of our gamer.

· Select, Recently Played to insert the Recently Played Field.

· Select, Gamer Score to insert the player's gamer score.

As you can see, Word has inserted quick part text fields that will represent the Data from our DIP. If you just type in some values in the DIP, you'll see the word document update.

Drag these quick part fields wherever you want in your document. We can even Style them like regular text, I'll make the gamer score red, bold, and increase the font size.

clip_image024

Now that our quick parts are in place, we need to update our score card template.

If you entered any data in the DIP, go ahead and clear it. Now we need to save the document to our local hard disk as a Word Document Template .dotx (yes, again).

We now have to navigate back to our Content Type settings and re-upload the document template. This will overwrite the old template with our new version which includes our quick part fields.

Click Site Actions >> Site Settings >> Modify All Site Settings >> Galleries: Content Types >> Gaming >> Gaming Score Card.

Select Advanced, and browse to upload our new template for the second time.

clip_image026

If you return to the Gamer Score Cards Document Library, Click New, our updated template should show up with all the quick part fields positioned.

So our word document is reading from the DIP the way we want it to, We just have to populate the DIP with our SharePoint data. Fortunately, Microsoft InfoPath has powerful tools that allow you to customize the Document Information Panel, as if it were a standard InfoPath form.

Launch InfoPath 2007. The Getting Started Wizard appears.

Under Design A Form, select Design a Form Template.

For the Form Base, we need to select "XML or Schema" and click OK

clip_image028

InfoPath will now prompt you for the URL of the Schema, All you have to enter is the URL of the SharePoint Site that houses your Content Type. (i.e. http://mylocalsharepointserver).

After you enter your credentials, InfoPath will present you with a list of all the Content Types that live in that SharePoint Site.

We will of course select our "Gamer Score Card" Content Type and click Next.

clip_image030

InfoPath tells you that it will create a Form Template based on our Content Type's Schema. Tell InfoPath thank you, and click Finish to start having fun.

What was just the Document Information Panel in Word, is a now a full-fledged form in InfoPath.

clip_image032

Now….We want to populate our word document, with Data from our wonderful SharePoint List. So the first thing we need to do is add a data connection to that list.

From the InfoPath Toolbar Click Tools >> Data Connections >> Add.

Select to create a Data Connection to Receive Data, then click Next.

clip_image034

For the Source of our Data Select SharePoint Library or List

clip_image036

Again, InfoPath will prompt you for the URL of your SharePoint Site, (http://yoursharepointserver)

You will now be presented with a list of all your SharePoint Lists, and Document Libraries. We have our information in a List called "Gamer Score Card Data". So we'll select that one.

clip_image038

InfoPath now prompts us to select the fields that we want to import as our Data Source. We'll check to select the Name, Recently Played Game, ID, and Gamer Score fields.

clip_image040

Click Next, Next again, and then Finish to create your data connection.

Our data is now a part of the DIP, lets start assigning the data to our fields.

To make this interesting, we'll convert the Title field in our InfoPath form to a drop down menu, where the user can select from a list of employees, once a name is selected, the rest of the information in the form will be populated.

The first step is to right click on the Title Field in our Form, and click Change To >> Drop-Down List Box.

clip_image042

Now we need to have our list box read from our Data Source.

Right click on the Title List Box and click Drop-Down List Box Properties.

For List box Entries, We need to select "Look up values from an external data source", For the Data Source, select "GamerScoreCardData" (Or the name of the Data Source Connection you created).

clip_image044

Click the button to the right of the Entries Field to browse fields in your data source.

Expand the dataFields node and click to select the Folder "GamerScoreCardData". Click OK

clip_image046

Back in the Drop-Down List Box Properties, we need to set the Value to Name and the Display Name to Name.

clip_image048

If we click OK to close our Drop-Down List Box Properties, and click File >> Preview >> Preview Form. We can now see our Drop-Down List reads from a the list of names in our SharePoint List.

clip_image050

Close the preview to return to our InfoPath design window.

Now we need to set up some actions so that when a user is selected, their Recently Played Game and Gamer Score are displayed.

Right click on the Title Drop-Down List Box, and click Drop-Down List Box Properties.

Click Rules and then Add to add our first rule.

We'll call this first rule "Set Recently Played Game"

This action will need to select the recently played game of the currently selected employee.

Click Add Action.

clip_image052

Change the action to, Set a field's value.

Click the Browse button, then expand the Properties Node and select the field that contains "Recently Played Game"

clip_image054

Now for the value, we need to select the data from our SharePoint list, and filter it by our currently selected item.

Click the Fx button for the Value, Click Insert Field or Group, Change the Data Source to "GamerScoreCardData" and click once to highlight "Recently Played Game".

With the field highlighted, click Filter Data.

clip_image056

Click Add to add our new filter.

Change the First Field to "Name".

Leave the Filter String to "Is equal to".

For the Third Field, Click the Drop-Down List to 'Select a field or group'

clip_image058

Change the Data Source to Main >> Expand the Core Properties Node and select Title.

clip_image060

Click Ok, and then OK again to close the filter condition as well as all the other Dialog Boxes.

clip_image062

clip_image064

Click File >> Preview >> Preview Form to Preview the form. Now when we select a name from the drop down list. The player's recently played game is displayed.

clip_image066

Close the form preview.

We now need to add another action to set the player's gamer score.

Right click the Drop-Down List Box, click Drop-Down List Box Properties.

Click Rules. Click Add to add another Rule. We'll call this "Set Gamer Score".

Click Add Action. Change the action to "Set a field's value"

Click the Browse Fields button, expand the properties node , select "Gamer Score"

clip_image068

For Value, click the Fx button, Insert Field or Group, Change the Data Source to "GamerScoreCardData" Expand the Nodes to highlight "Gamer_Score". Click Filter Data.

clip_image070

Add a new Filter

Change the First Field to "Name".

Leave the Filter String to "Is equal to".

For the Third Field, Click the Drop-Down List to 'Select a field or group'

Change the Data Source to "Main", expand the Core Properties node, select "Title"

clip_image072

Keep clicking OK to close all the dialog boxes, and then preview your form. Now when you select a name, the player's recently played game as well as the Gamer Score should be displayed.

It’s probably a good idea to save your form locally, just to have as a backup.

Now that we have the form functioning the way it should, we can delete the Recently Played Field, and the Gamer Score Field from the form layout. That way, all the user will see is the Name Drop down when opening the Word Document.

clip_image074

We can also change the "Title:" label to something more understandable, like "Employee Name: " I will also add some formatting to the label, this is all optional.

My final form is just a label that says employee name, and has a drop down list box.

clip_image076

Save this version of your form with a different filename, just so we can access the different stages of our form.

Now it’s time to publish this form to SharePoint.

Click File >> Publish >> As a Document Information Panel template… >> Click Next.

clip_image078

Finally Click Publish.

Navigate back to the Gamer Score Cards Document Library, and click New to create a new Score Card.

If we look at the DIP, we should see our drop down list box. Select a name and enjoy the fruits of your labor. Your word document is populated (and formatted) with the data from the SharePoint list, that you configured.

clip_image080

--Omar Stewart

        

Comments

Brian Brinley

excellent post! was working on something very similar and the screenshots are great.
at 3/26/2010 11:20 AM

luiz

hi there, i followed your tutorial, but my infopath shows nothing after I enter my sharepoint site

mine is sharepoints services (WSS, not MOSS).. is there a problem?
at 4/24/2010 7:59 PM

awaiK

Nice tutorial, but InfoPath can't connect to my SharePoint Application which is running at port 8080, is this might be a problem?
at 7/26/2010 6:23 AM

Nidhi

very nice tutorial!!!!
at 11/2/2010 3:45 PM

SHL

Simple and to the point.  Best example I've seen.  Thank you very much, Omar.

But, can a similar technique be used to populate a table within a word template, where each resulting document's table may contain a greatly differing number of rows based on the filter?

Please point me in that direction.  Thanks.
at 3/30/2011 4:03 PM

Doreen

Will the base "template" still be a Word Document which would potentially allow the user to track changes in the Word template?  That is a functionality that Word has that I'd like to preserve for my purposes. 
at 7/6/2011 11:55 AM

Omar

Thanks for the feedback guys.

Doreen,
If you would just like to track changes to the word template itself, you can do that in the word client itself. SharePoint won't monitor changes to the template though.

However, what SharePoint will store is a version history timeline of each document in the library. You get that just by enabling standard SharePoint Versioning in the document library settings.

SHL,
That may be a little tricky. The only way I can think of is programatically.

awaiK,
There may be some connection issues in your environment. Try to publish a standard infopath form library.
at 7/18/2011 12:21 PM

Nik

Hi Omar,

Just wondering, part of the list I have includes columns with Multiple lines of text, these don't see to show up on the list of fields to make available, is there anyway to get these on there? I am probably missing something simple!

Thanks
at 10/21/2011 11:43 AM

Rushikesh

Awesome post dude! Everything worked exactly as above.
at 12/6/2011 8:33 PM

Lorraine

Omar this is a fantastic post!! The steps are explained clearly and simply. Excellent use of screenshots. My problem's solved and feedback's been great, thanks to you. Thanks a lot.
at 4/17/2012 9:07 AM

DEBOUGE

Nice stuff, very clearly expalined and it works. 

Does a similar procedure exist to populate a Excell document from a SharePoint list?

Does the same procedure apply for SharePoint 2010?
at 10/4/2012 7:26 AM

mayank

Your legend. I tried this SP2010 and O2010...all looks good
at 12/12/2012 7:05 PM

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Your Name *


e-mail address *


Website (optional)


Comment *


Attachments

 Subscribe

  GigWerks RSS  Gig Werks Mailing List 

 Contact Us

 Connect

 Resources

  On Demand SharePoint Webcast Recordings
  Upcoming Webinars
  SharePoint Resources
  Business Intelligence Resources
  Gig Werks Website



©2009 Gig Werks. All rights reserved. Privacy Policy