Welcome to MSDN Blogs Sign in | Join | Help

Inserting and Swapping Building Blocks

In my first post on building blocks, I talked about the different types of building blocks available and the concept of building blocks being able to "know" where to get inserted. For example, headers and footers get inserted in the header or footer region of the document…imagine that :) In today's post I am going to talk about inserting and swapping out building blocks in Word 2007. Here's a video showing what I talk about in this post.

Inserting Building Blocks

There are many types of building blocks (cover pages, headers, footers, text boxes, etc.) available to create good looking documents quickly. To help you easily insert different types of building blocks that look good together, we have coordinated building blocks across the Cover Page, Headers, Footers, and Text Boxes galleries with unique names. These names indicate which building blocks are meant to complement one another. Nothing prevents you from mixing and matching, but items with the same name across the four galleries are designed to look great together.

Here is a screenshot of the Cover Page and Header galleries with the coordinated names circled:

Here is a screenshot of a document with inserted Austere cover page, header, footer and text box building blocks:

Building Blocks and Content Controls

Many of the building blocks we provide have designated regions to type content, such as the title and date of the document. The cool thing is that these regions are in fact content controls that are mapped to document properties. By mapping these content controls to document properties, the text you type within them will be persisted even if you change your cover page, header, or footer.

For example, when you type within the Title content control in a cover page document building block, this text is mapped to the Title property of the document. With this mapping in place, any building block containing content controls bound to the Title property will automatically be populated with the document title. Jonathan's 21st Century Document video demonstrates this concept and can be viewed here. Basically, if you wish to update the title of your document, you only have to do it once, within any of the content controls that are bound to the Title document property, and all of the other content controls bound to the Title document property will be updated automatically. Nice.

For example, here is a document where I've inserted cover page, header and footer building blocks, without adding any content within the Title or Subtitle content controls.

Now, if I change any instance of a Title or Subtitle content control, this will result in a global change of all the instances of the Title or Subtitle because all instances of Title and Subtitle content controls are mapped to the corresponding Title and Subtitle properties of the document. For example, here's the same document with the Title "Building Blocks" and the Subtitle "So Cool":

Swapping Building Blocks

Any building block that is unique to the document or section, such as a cover page or header, can be swapped using the same gallery used to insert them. For example, inserting a new cover page will replace any existing cover page and inserting a header or footer will replace any existing header or footer for the current page. On the other hand, building blocks like tables and text boxes that often appear multiple times will, as expected, not replace existing objects.

Swapping building blocks also preserves content controls that are bound to document properties. Let's say I have a cover page with the following content controls: title, subtitle, date, and abstract. I then swap that cover page with another cover page that contains the same content controls. Guess what? All the content controls that are bound to document properties are preserved when I swap out the original cover page. Very cool. Here is a screenshot of swapping one cover page for another, while preserving content controls:

Building Blocks and Formatting

In order to more closely relate the formatting of building blocks with your documents we have closely tied building blocks to the document's theme. By relating building blocks to themes, building blocks will adapt nicely to changes in the look of the document as a result of changing the theme or the style set applied. Check out Stuart's blog here.

Here are two screenshots of Cubicle cover page, header, footer, and text box building blocks with the Office and Equity themes respectively:

All of our built-in building blocks are also designed to adapt to changing page orientation, paper size, and margins as well, so you don't have to worry about rearranging your cover page if you decide to make layout adjustments to your document.

Going back to the above example of Cubicle building blocks, changing the page orientation to landscape will result in the following document:

Notice that all the building blocks scale appropriately based on the page dimensions.

Next Time

In my next post on building blocks, I will talk about creating your own building blocks in Word 2007.

Let me know if you have any specific questions or comments that you would like me to address here or in future posts.

Zeyad Rajabi & Jonathan

Published Wednesday, November 22, 2006 5:15 AM by wrdblog

Comments

# re: Inserting and Swapping Building Blocks

What happens when I create a document using building blocks extensively and then distribute it as a Word 2003 .doc?  Am I better off creating a .pdf in that case?

Wednesday, November 22, 2006 10:29 AM by Eric j

# re: Inserting and Swapping Building Blocks

Eric – That is a great question. Using the binary doc format will not affect  the look of your document.

However, content within content controls will become static. That is, the content will no longer be associated with content controls. For a better understanding of compatibility issues please see the blogs in this link:

http://blogs.msdn.com/microsoft_office_word/archive/tags/compatibility/default.aspx

Zeyad Rajabi (MS)

Wednesday, November 22, 2006 3:41 PM by wrdblog

# re: Inserting and Swapping Building Blocks

Can I use building blocks to add repeated content to a document? For example, supposing I want to have a whole section of a document for each of several repeated entities, e.g vehicles or buildings.  How do I use building blocks to create repeated sections and bind them to custom XML?

Thursday, November 30, 2006 12:20 PM by Kim Jones

# re: Inserting and Swapping Building Blocks

Hi Kim,

That is a great scenario you mention. Out of the box there is no way to accomplish the task you mention. You will need to create or use a custom solution that allows for creating repeated sections based on content controls. A good reference for writing such a solution would be to take a look at what Matt Scott has done by watching the Channel 9 video at: http://channel9.msdn.com/Showpost.aspx?postid=254520

Zeyad Rajabi (MS)

Friday, December 01, 2006 7:27 PM by wrdblog
New Comments to this post are disabled
 
Page view tracker