Microsoft Office 2007 ships with 84 built-in SmartArt graphics layouts. It is possible to create new template files to add new styles to your SmartArt graphics gallery.
I must caution you that this is not an easy process. You should be comfortable with finding files using Windows Explorer, as well as zipping (compressing) and unzipping files. You will also be editing some fairly complex markup language to achieve the new style.
Despite the caution, the process of taking an existing layout and changing it slightly is fairly straightforward. This chapter walks through two case studies:
Both of these changes are relatively simple. They involve taking a current definition and changing a few words in the specification. They are designed to be enough to get your feet wet, to introduce you to the topic of SmartArt extensibility.
If you are the graphics design guru for a corporation, you might want to completely design your own new layouts. The concepts of building a layout from scratch are complex; you have to deal with scalability and aspect ratios. This topic alone is worthy of a book.
Now it’s time to customize an existing layout by changing the primary shape used in the graphic. The images in this example walk you through changing the Basic Process layout to have hexagon shapes instead of rounded rectangles.
If you want to follow along, try using a slightly different example. Select a different layout as a starting point and attempt to change to another shape.
The first step is to find a built-in layout that is already close to matching your desired layout:
As you click on the icons in the gallery, the right side of the Choose a SmartArt Graphic dialog box shows a thumbnail of the layout. It also shows a name in bold and a description. Make a note of these values, because you will be changing them in step 4 of this process.
Note
If you’ve obtained the Office 2007 Software Development Kit, the XML files for all 84 SmartArt graphics layouts are in the kit. You can skip steps 2and 3 if you already have the XML file.
After you identify a layout in step 1, click OK to insert that layout into the document. You don’t need to edit the layout in any way. Leave it in the default state with [Text]
placeholders, as shown in Figure 9.1.
Figure 9.1 Insert a blank graphic using the similar built-in layout.
Save the file as an Office 2007 document. For Excel, this means using either the .xlsx
or .xlsm
extension. Do not use the .xlsb
binary format, because it does not allow you to edit the document.
Note the path and filename of the document, because you will need this information in step 3, and close the file.
Although Office 2007 documents have file extensions such as .xlsx
, .docx
, and .pptx
, they are actually stored as zip files. If you rename the document with a .zip
extension, you can use any compression utility such as WinZip to access the contents of the file. Follow these steps to rename and open the document as a zip file:
Figure 9.2 Find the file in Windows Explorer and choose Rename.
.xlsm
extension to .zip
and press Enter.Figure 9.3 Windows warns you that changing file extensions is dangerous. Click OK.
layout1.xml
from the zip file. The steps for this procedure are different if you are using WinZip or the native Windows Vista zip functionality.If you are using Windows’ built-in compressed folder utility, you might initially see that the zip file contains folders such as _rels
, docProps
, and xl
, as shown in Figure 9.4.
Figure 9.4 Windows Vista shows only the top level of the zip file here.
If this is the view that you see, follow these steps:
xl
folder.diagrams
folder.layout1.xml
and choose Copy.layout1.xml
to your folder.If you are using WinZip or a similar utility, the window probably shows you the complete file structure. Folders are listed on the right side, as shown in Figure 9.5.
Figure 9.5 WinZip shows you the complete file contents.
To extract the file, follow these steps:
layout1.xml
entry and choose Extract (refer to Figure 9.5).When creating a new layout, you should provide a name and description for the layout. This information will be visible in the gallery of SmartArt graphics. You also have to choose a unique ID for the layout style. The UniqueID should contain no spaces and not match any other SmartArt graphic layout IDs.
For my example, these values work:
However, before doing that, you need to open the XML file for editing. You should now have layout1.xml
available in Windows Explorer. Right-click the file and choose Open With, Notepad, as shown in Figure 9.6.
Figure 9.6 Choose to open the file with Notepad.
Note
If you are a developer and already have an XML editor, by all means, use it instead of Notepad.
In Notepad, choose Format, Word Wrap so that the XML file is visible in the width of the Notepad window.
Do not be alarmed at the apparent jumble of XML codes in the file, as shown in Figure 9.7. You will be surgically editing four items in the file. Editing is not as overwhelming as it seems.
Figure 9.7 Despite the appearances, editing this file is not overwhelming.
Choose Edit, Find to search for the UniqueID tag. The current value for the UniqueID tag should be something like
uniqueId="urn:microsoft.com/office/officeart/2005/8/layout/process1"
Change this line to use your chosen UniqueID. It is important that each UniqueID be unique. Don’t save several templates with different filenames and identical UniqueIDs and expect it to work.
Choose Edit, Find to search for title. Depending on the author of the original layout, this tag might be filled in or blank. For example, the following tag has a blank value:
<dgm:title lang="" val=""/>
Edit the tag to include your title, such as this:
<dgm:title lang="" val="Hexagon Process"/>
Choose Edit, Find to search for dgm:desc
. This tag is currently blank. The tag looks like this:
<dgm:desc lang="" val=""/>
Edit the tag to include your description, such as this:
<dgm:desc lang="" val=" A process chart using hexagons.
Suitable for Level 1 and Level 2 text. Created by MrExcel."/>
The SmartArt graphics gallery contains seven categories. An eighth category called “Other” is available for your use. You can place your new layout in one or more categories. On the same line of code, each layout is also assigned a priority, from 1 to 32000. Your current layout1.xml
file might have a tag like this:
<dgm:cat type="process" pri="1000"/>
If you want your custom layout to appear just after the original layout, edit that tag to change the priority to 1001. If you want your custom layout to appear first, use pri=1
. If you want your layout to appear in two different categories, edit the file to have two tags, like this:
<dgm:cat type="process" pri="1"/><dgm:cat type="list" pri="1"/>
Remember, the valid values for categories are list
, process
, cycle
, hierarchy
, relationship
, matrix
, pyramid
, and other
.
Note
You may find a dgm:cat
tag where the type is convert
. Leave this tag alone. Editing this tag will not have any impact on your layout.
In the current example, my file uses a rounded rectangle as the current shape. There could be many shapes in your current layout. Choose Edit, Find to locate all occurrences of <dgm:shape type
.
This example has three such tags. One occurs after <LayoutNode Name="node"
. This is the definition for the main shape. Other occurrences might appear after node="SibTrans"
for the connector shapes.
In this case, the type="RoundRect"
should be enough of a clue that this is the tag you are trying to edit.
To change to a hexagon, change
<dgm:shape type="roundRect"
to
<dgm:shape type="hexagon"
Note
A complete list of shapes is shown in Table 9.1.
Choose File, Save to save layout1.xml
.
To use the SmartArt graphics custom definition, you have to wrap the Layout1.xmls
file in a glox
file. Microsoft provides one sample .glox
file, but at press time, they had not decided where Sample.glox would be available. If you visit http://www.MrExcel.com/SmartArtFiles.html
, I specify where you can find this file.
The Sample.glox
file is really a zipped archive. Follow these steps to unzip it:
Sample.glox
. Choose Open With…and select Winzip.layout1.xml
file in the archive. Click on this file and press the Delete key to remove the existing layout1.xml
.layout1.xml
file into the Winzip window.HexProcess.glox
.Figuring out the location of your templates folder is frustrating. It is in a different location if you are using Windows XP than it is if you use Windows Vista. If you can remember an arcane code, you can force Windows Explorer to navigate to this folder. Follow these steps:
%appdata%MicrosoftTemplates
.glox
file to this folder.Any changes you make to .glox
files in the SmartArt graphics folder will not be recognized by Office 2007 until you restart the application as follows:
Figure 9.8 Success! The new style is available in the gallery.
Figure 9.9 shows a SmartArt diagram created with the new style.
Figure 9.9 A diagram created with the new layout.
The following sections introduce additional tags in the .glo
file. However, this is by no means an exhaustive list.
In the previous example, you found the dgm:shape type
tag to change the shape from rounded rectangles to hexagons. This time, open the .XML
file for editing and locate the dgm:shape type
tag:
<dgm:shape type="roundRect"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/
relationships" r:blip="">
Shortly after this tag is a dgm:constr
tag. This tag says that the height of the shape will be 60% of the width of the shape:
<dgm:constr type="h" forName="" refType="w" refForName=""
fact="0.6"/>
Say that you want the shape to be more square instead of oblong. If you want to make the height of the shape to be 100% as wide as the shape, convert the tag to
<dgm:constr type="h" forName="" refType="w" refForName=""
fact="1.0"/>
If you want to make the initial shape be a certain number of millimeters tall, remove the refType="w"
value from the tag. Enter the number of millimeters as the fact
. In the following example, the hexagons always start as 50 millimeters tall:
<dgm:constr type="h" forName="" refForName="" fact="50"/>
In the .glo
file, three shapes are defined with <dgm:shape type
. The first shape is the main node shape. The next shape is a type Conn
and appears after the LayoutNode name="SibTrans"
tag. This refers to the arrows between the shapes. The final shape is also a type Conn
and appears after the LayoutNode name="connectorText"
tag. If you follow the complete text of this tag, you see the parameter hideGeom="1"
. This parameter means that the shape is hidden.
The current diagram has three shapes, although one is hidden. To rotate the shapes, add a rot
parameter to the dgm:shape type
tag. This parameter can go after the blip=""
parameter.
The following code rotates the hexagons by 60 degrees:
<dgm:shape type="roundRect"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/
relationships" r:blip="" rot="60">
The following code rotates the connector arrows by 180 degrees:
<dgm:shape type="conn"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/
relationships" r:blip="" rot="180">
After you make these changes to layout1.xml
, wrap it in the Sample.glox
file and save it to the templates folder. Then exit and restart the application. Figure 9.10 shows the result of rotating the shapes.
Figure 9.10 This diagram has the arrows rotated 180 degrees and the hexagons rotated 60 degrees.
Early in the beta process for Microsoft Office 2007, several beta testers and I were discussing SmartArt graphics in the beta newsgroups. One of the conversations noted that the Bending Picture Accent List layout is a great layout, but the picture placeholders are annoying (see Figure 9.11).
Figure 9.11 This layout would be great if there were a version without the picture icons.
The intuitive way to remove the placeholder circles does not work. Go ahead and try it. Click on a circle (outside the picture icon) to select it and press the Delete key. Nothing happens.
The posts in the newsgroup expressed frustration that there is not an easy way to delete the images from the built-in style. The desire to produce a Bending Picture Accent List without pictures actually drove a number of people to figure out the extensibility documentation.
The following instructions assume that you followed the first example in the chapter. Only step 4 has the necessary details:
.xlsm
to .zip
. Extract layout1.xml
from the zip file.layout1.xml
in Notepad. The image placeholders are called a blip. Choose Edit, Find to search for blipph. Expand the selection in both directions to encompass these lines:
<dgm:shape type="ellipse"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/
relationships" r:blip="" blipPhldr="1"><dgm:adjLst/></dgm:shape>
Delete the preceding text and replace it with this text:
<dgm:shape/>.
Edit the UniqueID, Name, Description, and Priority as described earlier. Change the priority from 5000
to 5001
.
layout1.xml
. Wrap it in Sample.glox
and save the file as BList3.glox
in the templatesSmartArt graphics
folder.Figure 9.12 The new layout is available in the gallery.
Figure 9.13 shows the completed diagram with the new layout.
Figure 9.13 This diagram is created with the new bending list layout.
The customizations described here are only the tip of the iceberg of what can be accomplished. The complete specification spans 4,000 printed pages.
If you need to limit the layouts available in your organization, it is possible to modify Office’s SmartArt functionality to show only custom layouts. Microsoft provides a Registry key that instructs Office not to offer any of the 84 built-in styles.
The key is located at: HKEY_CURRENT_USERSoftwareMicrosoftOffice12.0CommonSmartArt Graphics.
You can then populate your templates folder with custom layout .glox
files.
The Office Software Development Kit (SDK), which is available from MSDN, offers the individual .glox
files for the 84 built-in styles. If you want to offer only a subset of the 84 styles, you could follow these steps:
.glox
files from the SDK..glox
files to the templates folder.Table 9.1 lists all the shape names available in SmartArt definitions.
Table 9.1 Shape Codes Valid in SmartArt Graphics Layout Files
This is the end of the discussion of SmartArt graphics. The next two chapters cover the other drawing tools available in Office: WordArt and Shapes.