<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type='text/xsl' href='http://bvisual.spaces.live.com/mmm2008-07-24_12.50/rsspretty.aspx?rssquery=en-US;http%3a%2f%2fbvisual.spaces.live.com%2fcategory%2fVisio%2ffeed.rss' version='1.0'?><rss version="2.0" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:msn="http://schemas.microsoft.com/msn/spaces/2005/rss" xmlns:live="http://schemas.microsoft.com/live/spaces/2006/rss" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>bVisual: Visio</title><description /><link>http://bVisual.spaces.live.com/?_c11_BlogPart_BlogPart=blogview&amp;_c=BlogPart&amp;partqs=catVisio</link><language>en-US</language><pubDate>Fri, 15 Aug 2008 09:15:47 GMT</pubDate><lastBuildDate>Fri, 15 Aug 2008 09:15:47 GMT</lastBuildDate><generator>Microsoft Spaces v1.1</generator><docs>http://www.rssboard.org/rss-specification</docs><ttl>60</ttl><cf:parentRSS>http://bVisual.spaces.live.com/blog/feed.rss</cf:parentRSS><live:type>blogcategory</live:type><live:identity><live:id>3697690708899476393</live:id><live:alias>bVisual</live:alias></live:identity><cf:listinfo><cf:group ns="http://schemas.microsoft.com/live/spaces/2006/rss" element="typelabel" label="Type" /><cf:group ns="http://schemas.microsoft.com/live/spaces/2006/rss" element="tag" label="Tag" /><cf:group element="category" label="Category" /><cf:sort element="pubDate" label="Date" data-type="date" default="true" /><cf:sort element="title" label="Title" data-type="string" /><cf:sort ns="http://purl.org/rss/1.0/modules/slash/" element="comments" label="Comments" data-type="number" /></cf:listinfo><item><title>Flags of the World</title><link>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!521.entry</link><description>&lt;p&gt;I was recently asked how to add a country flag to Visio Org Chart shapes automatically.  Well, as I am currently working with world data at the moment, I have taken up the challenge.  Firstly, the CIA have an excellent source of information, called the World Factbook ( &lt;a title="https://www.cia.gov/library/publications/the-world-factbook/" href="https://www.cia.gov/library/publications/the-world-factbook/"&gt;https://www.cia.gov/library/publications/the-world-factbook/&lt;/a&gt; ).  You can find all sorts of information about every country in the world, including, of course, their flags.  There are over 240 countries at the moment, and there are various codes used by different systems to identify them.  Even the name may not be the same, for example, do I live in UK, United Kingdom, Great Britain, United Kingdom of Great Britain and Northern Ireland or just plain old England?  Answers on a post card, please, addressed to …..? 
&lt;p&gt;Alternatively, a country can be identified accurately with a code, but you need to know which system is being used.  United Kingdom can be identified by GB in the Iso 2 character system, or 826 in the Iso numeric system, or UK in the FIPS 10 system.  The CIA World Factbook utilises the FIPS 10 code, so consequently, all of the country related web pages and images are coded with this system. 
&lt;p&gt;I have already created an Access database with all this information, so I decided to use this knowledge to create a Flags of the World Visio Master. 
&lt;p&gt;&lt;a href="http://j8ysfq.blu.livefilestore.com/y1pX28rybzD8B84a-YwSPcArnxwTOIg8v5azRdeCVNxkk92Wtor0nA8RF4yIkXnnDk82LxMuG1wjAw?PARTNER=WRITER"&gt;&lt;img title=image style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=445 alt=image src="http://j8ysfq.blu.livefilestore.com/y1phd1HfxvrIfNNy3JunEI2iGTeGCdVlaeFSpexZmauGEvff_AXUmYoka0yZt3gG3_KbKRvwjscwmBKrvehgH04TQ?PARTNER=WRITER" width=606 border=0&gt;&lt;/a&gt; 
&lt;p&gt;I wrote some VBA to download the gif files from CIA website, and imported them into a specially prepared group shape.  Each image shape was automatically named with the FIPS 10 code, and the Width and Height formulae were written to be 0 if the parent group shape does not represent relevant country. 
&lt;p&gt;&lt;a href="http://j8ysfq.blu.livefilestore.com/y1pKliQQjE_NqBnqjwEKeOZlu3bP979OPe29iliGf49_7dqXBnfBdjDk9-N411s9V_uiqcOzvaT7_d4JHzCpAXnXQ?PARTNER=WRITER"&gt;&lt;img title=image style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=442 alt=image src="http://j8ysfq.blu.livefilestore.com/y1p2Z-J9WyBMPfpzRSzOfm5DeGRM8rMN4M2E_nx3E9EvaYXzM_aQdcF7acG1XO9qE3hOIfBEHqy8vLYbtJyveq9xg?PARTNER=WRITER" width=612 border=0&gt;&lt;/a&gt; 
&lt;p&gt;The ShapeSheet of the parent shape was loaded with semi-colon separated lists of country related data, mainly pulled from the CIA website.  The Prop.Country Shape Data row is a fixed list so that the user can select a country by its name.  The other Shape Data rows are all guarded because their values are pulled via the Index of selected country name, from the User defined cells. 
&lt;p&gt;&lt;a href="http://j8ysfq.blu.livefilestore.com/y1pmKK5JjkyfmatZnOikSWULWxBYywOOIcc_7I9BsA3_OHrHgwbrfMDAyqfcV_FvaesVQ9gpKvgUy0KQtFCMgcI6A?PARTNER=WRITER"&gt;&lt;img title=image style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=469 alt=image src="http://j8ysfq.blu.livefilestore.com/y1p4uSZ3x8CnPxQuGg_KnULRDClqpmnaUuZ6Yj6ZgRyiqSvuqch7b3o2gCJRM__qRb43A0KGvHMQWV9qTNz2_GFiw?PARTNER=WRITER" width=611 border=0&gt;&lt;/a&gt; 
&lt;p&gt;ShapeSheet of the GB sub-shape, below, showing that the Width and Height is 0, if the shape Name is not equal to the Prop.Fips10 value in the parent shape.  Notice that the Width and Height formulae maintain the original aspect ratio of the flag image. 
&lt;p&gt;&lt;a href="http://j8ysfq.blu.livefilestore.com/y1p0Exnm2D1mOVZS8N61M6krlYcTGoqpMxaL5R36UUhKtxdNNSFjjBi45uC4wZHUOaWW1WFjjJdUcQvyCQuc4Yxeg?PARTNER=WRITER"&gt;&lt;img title=image style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=122 alt=image src="http://j8ysfq.blu.livefilestore.com/y1pjzNmhcmmF9fzsOGsgOT_VHderrRrroJUVaM-FUPXtPGO3zd4EN-IlA5YHTVTZ6q1Rnx8p-DNpggrScnNDWovGg?PARTNER=WRITER" width=608 border=0&gt;&lt;/a&gt; 
&lt;p&gt;This provides a Flags of the World Master, but I also created a Flags of the World Small Master because the first one uses the large flag images from the CIA website, but the second one uses the small image files, and thus uses less file size. 
&lt;p&gt;&lt;a href="http://j8ysfq.blu.livefilestore.com/y1psN840I9oAfLl5gTNcURJKS4DBBQvvPO-i_ylVze_wkI1B2DG3jnclGEGf05xFQWCUR7DSYCeftj3ZNyoGesDLg?PARTNER=WRITER"&gt;&lt;img title=image style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=431 alt=image src="http://j8ysfq.blu.livefilestore.com/y1pnuo6_GgHpgZjvcyJ0bYZweL3bSNlqq7Z5txKON8uFxljwTfIAZNVOa-7o-r5P0jblu350Vvl1kRO5_oe-rfGkg?PARTNER=WRITER" width=606 border=0&gt;&lt;/a&gt; 
&lt;p&gt;I have also added context sensitive hyperlinks to the CIA website, Maps Live, Google Maps and Google Earth, and one to bVisual’s website…. 
&lt;p&gt;OK, now we are halfway there … we actually want to apply the map icon to any shape that has a Shape Data value that is a country name, but we don’t know the name of this Shape Data row in advance…. 
&lt;p&gt;Visio 2007 Professional Data Graphics has Icon Sets, but you can only have a maximum of 5 icons in each set … certainly not enough for over 240 countries.  So, why not use an Icon Set as a placeholder for a country flag, then replace the Icon Set image with the flag for the country whose value is in the Shape Data row specified by the Icon Set Graphic Item? 
&lt;p&gt;That is exactly what I did in the screen-shot below: 
&lt;p&gt;&lt;a href="http://j8ysfq.blu.livefilestore.com/y1ps7ZJu2f8wAdSRtJiHLY8BlbaHHavWiqaVokV-VUbEXXBNgOFtLfr0RDxru4DTlmOaO1hQd9kK0b71vJQNPlxzQ?PARTNER=WRITER"&gt;&lt;img title=image style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=408 alt=image src="http://j8ysfq.blu.livefilestore.com/y1pu3nTrn-P6bPELedFw8R9BmY0Kk6Iyjk7fg51uuKYh_T9pGwMbbU_AKw5nJDTSZVkIEiZtxibPyou4pnO42zNLA?PARTNER=WRITER" width=605 border=0&gt;&lt;/a&gt; 
&lt;p&gt;I duplicated an existing Icon Set (Trend Arrow 1) in the Drawing Explorer, renamed it as &lt;strong&gt;FlagPlaceholder&lt;/strong&gt;, then amended it to have one image sub-shape, called &lt;strong&gt;Flag&lt;/strong&gt;. 
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;&lt;a href="http://j8ysfq.blu.livefilestore.com/y1psv3Wo1fAOlYwCiayZWmhi2xHoxozhr-G1R69ynFv9weW1Zb8teXKfcmzuLXH52U5aFUXJ_rwPyy0ohYig0pD2w?PARTNER=WRITER"&gt;&lt;img title=image style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=251 alt=image src="http://j8ysfq.blu.livefilestore.com/y1pKdi4Oe2Mx8SWi74gdV57Xyss_AhNELsd-_df9TH13calSYq2yXz2Kc5tFF3j1KIvGWBW7Rl51bn-CNkKu6uTiQ?PARTNER=WRITER" width=607 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Thus the Icon Set becomes available in the Data Graphics editor, and you can select the Shape Data row that contains the name of the country.  You only need to have one qualifying value, so I entered &lt;strong&gt;does not contain *&lt;/strong&gt; , because I assume that there is no country in the world with that character in its name. 
&lt;p&gt;The attached stencil, &lt;strong&gt;FlagsOfTheWorld.vss &lt;a title="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/FlagsOfTheWorld.zip" href="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/FlagsOfTheWorld.zip"&gt;http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/FlagsOfTheWorld.zip&lt;/a&gt; &lt;/strong&gt;, includes the macro UpdateFlags, which will then change the flag for each selected shape. 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pAPRxd6EdslR5H6KqmZYWan71KunZADzGlkJ99eY8_HrLt98BDSLW1sVPI0n5aKJj33OKV4lJvFo?PARTNER=WRITER"&gt;&lt;img title=image style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=581 alt=image src="http://j8ysfq.blu.livefilestore.com/y1pvSUlSgwzpLNy4_UC2USjUt5TCTLcHmdcLfr7rHsR3hQa1BvskeliEWJxBmIEk71JNnHRrMmN_eN80hpi9WDaqQ?PARTNER=WRITER" width=606 border=0&gt;&lt;/a&gt; 
&lt;p&gt;So, when the macro is run, the test shapes now show the flags for each country…. 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pxqLA5kIN6Lz7H8Qx7_63pj4WKBUNq43hnC2q_iv03itwTM0BmBmh6BZ_1PubpOOJvGU5uF5MstM?PARTNER=WRITER"&gt;&lt;img title=image style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=497 alt=image src="http://j8ysfq.blu.livefilestore.com/y1pHXq1jYQomYSKGc2O4yUmxNRDKgVLp0yGKsFxxUeGERU8-yNcHXFCKvuunTrpfWpKa7VZjPLr7tDmVJD8sXupgA?PARTNER=WRITER" width=608 border=0&gt;&lt;/a&gt; 
&lt;p&gt;&lt;font color="#000080"&gt;Option Explicit&lt;/font&gt;&lt;br&gt;&lt;font color="#008000"&gt;'David Parker&lt;br&gt;'July 2008&lt;br&gt;'No warranties at all with this code&lt;br&gt;'Use at you own risk&lt;/font&gt; 
&lt;p&gt;&lt;font color="#000080"&gt;Public Sub&lt;/font&gt; UpdateFlags()&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; shp As Visio.Shape&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; subshp As Visio.Shape&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; imgshp As Visio.Shape&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; flagExists &lt;font color="#000080"&gt;As Boolean&lt;/font&gt;&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; cel As Visio.Cell&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; celPrecedent As Visio.Cell&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; aryPrecedents() As Visio.Cell&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; country&lt;font color="#000080"&gt; As String&lt;/font&gt;&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; aryCountries() &lt;font color="#000080"&gt;As String&lt;/font&gt;&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; aryCodes() &lt;font color="#000080"&gt;As String&lt;/font&gt;&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; mstFlag As Visio.Master&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; code &lt;font color="#000080"&gt;As String&lt;/font&gt;&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; idx &lt;font color="#000080"&gt;As Integer&lt;/font&gt;&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; filePath &lt;font color="#000080"&gt;As String&lt;/font&gt;&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; flagShp As Visio.Shape&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; shpWidth &lt;font color="#000080"&gt;As Double&lt;/font&gt;&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; shpHeight &lt;font color="#000080"&gt;As Double&lt;/font&gt;&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; shpAspectRatio &lt;font color="#000080"&gt;As Double&lt;/font&gt;&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; flagWidth &lt;font color="#000080"&gt;As Double&lt;/font&gt;&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; flagHeight &lt;font color="#000080"&gt;As Double&lt;/font&gt;&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; flagAspectRatio &lt;font color="#000080"&gt;As Double&lt;/font&gt;&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; cloneShp As Visio.Shape&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; cloneMst As Visio.Master 
&lt;p&gt;&lt;font color="#000080"&gt;On Error Resume Next&lt;/font&gt;&lt;br&gt;    &lt;font color="#000080"&gt;Set&lt;/font&gt; mstFlag = ThisDocument.Masters(&amp;quot;Flags Of The World&amp;quot;)&lt;br&gt;    &lt;font color="#000080"&gt;If&lt;/font&gt; mstFlag &lt;font color="#000080"&gt;Is Nothing Then&lt;/font&gt;&lt;br&gt;        &lt;font color="#000080"&gt;Exit Sub&lt;/font&gt;&lt;br&gt;    &lt;font color="#000080"&gt;Else&lt;/font&gt;&lt;br&gt;        aryCountries = Split(mstFlag.Shapes(1).Cells(&amp;quot;Prop.Country.Format&amp;quot;).ResultStr(&amp;quot;&amp;quot;), &amp;quot;;&amp;quot;)&lt;br&gt;        aryCodes = Split(mstFlag.Shapes(1).Cells(&amp;quot;User.Fips10&amp;quot;).ResultStr(&amp;quot;&amp;quot;), &amp;quot;;&amp;quot;)&lt;br&gt;    &lt;font color="#000080"&gt;End If&lt;/font&gt;&lt;br&gt;&lt;font color="#008000"&gt;    'Need a temporary writeable file need&lt;br&gt;    'You may need to change this but it needs to be gif extension&lt;/font&gt;&lt;br&gt;    filePath = Replace(Replace(ThisDocument.FullName, &amp;quot;.vss&amp;quot;, &amp;quot;.gif&amp;quot;), &amp;quot;.vsd&amp;quot;, &amp;quot;.gif&amp;quot;)&lt;br&gt;    &lt;font color="#008000"&gt;'Get the current shape(s)&lt;/font&gt;&lt;br&gt;    &lt;font color="#000080"&gt;For Each&lt;/font&gt; shp In Visio.ActiveWindow.Selection&lt;br&gt;        &lt;font color="#000080"&gt;If Not&lt;/font&gt; shp.DataGraphic &lt;font color="#000080"&gt;Is Nothing Then&lt;/font&gt;&lt;br&gt;            &lt;font color="#000080"&gt;For Each&lt;/font&gt; subshp &lt;font color="#000080"&gt;In&lt;/font&gt; shp.Shapes&lt;br&gt;                &lt;font color="#000080"&gt;If &lt;/font&gt;subshp.CellExists(&amp;quot;User.msvCalloutType&amp;quot;, Visio.visExistsAnywhere) &amp;lt;&amp;gt; 0 &lt;font color="#000080"&gt;Then&lt;/font&gt;&lt;br&gt;                    &lt;font color="#000080"&gt;If &lt;/font&gt;subshp.Cells(&amp;quot;User.msvCalloutType&amp;quot;).ResultStr(&amp;quot;&amp;quot;) = &amp;quot;Icon Set&amp;quot; &lt;font color="#000080"&gt;Then&lt;/font&gt;&lt;br&gt;                        &lt;font color="#008000"&gt;'We know that this shape is an Icon Set&lt;/font&gt;&lt;br&gt;                        &lt;font color="#000080"&gt;If&lt;/font&gt; subshp.Name = &amp;quot;FlagPlaceholder&amp;quot; &lt;font color="#000080"&gt;Then&lt;/font&gt;&lt;br&gt;&lt;font color="#008000"&gt;                            'We know that the FlagPceholder exists&lt;br&gt;                            'Get the shape aspect ratio&lt;/font&gt;&lt;br&gt;                            shpWidth = subshp.Cells(&amp;quot;Width&amp;quot;).ResultIU&lt;br&gt;                            shpHeight = subshp.Cells(&amp;quot;Height&amp;quot;).ResultIU&lt;br&gt;                            shpAspectRatio = shpWidth / shpHeight&lt;br&gt;                            &lt;font color="#000080"&gt;For Each&lt;/font&gt; imgshp&lt;font color="#000080"&gt; In&lt;/font&gt; subshp.Shapes&lt;br&gt;                                &lt;font color="#000080"&gt;If&lt;/font&gt; imgshp.Name = &amp;quot;Flag&amp;quot; &lt;font color="#000080"&gt;Then&lt;/font&gt;&lt;br&gt;&lt;font color="#008000"&gt;                                    'Found the Flag shape&lt;/font&gt;&lt;br&gt;                                    &lt;font color="#000080"&gt;Set&lt;/font&gt; cel = subshp.Cells(&amp;quot;User.msvCalloutIconNumber&amp;quot;)&lt;br&gt;                                    &lt;font color="#000080"&gt;If&lt;/font&gt; UBound(cel.Precedents) = 1 &lt;font color="#000080"&gt;Then&lt;/font&gt;&lt;br&gt;&lt;font color="#008000"&gt;                                        'Get the value in the precedent cell&lt;/font&gt;&lt;br&gt;                                        aryPrecedents() = cel.Precedents&lt;br&gt;                                        &lt;font color="#000080"&gt;Set&lt;/font&gt; celPrecedent = aryPrecedents(1)&lt;br&gt;                                        country = celPrecedent.ResultStr(&amp;quot;&amp;quot;)&lt;br&gt;                                        idx = getLookup(country, aryCountries)&lt;br&gt;                                       &lt;font color="#000080"&gt;If&lt;/font&gt; idx &amp;gt; -1 &lt;font color="#000080"&gt;Then&lt;/font&gt;&lt;br&gt;&lt;font color="#008000"&gt;                                            'We found a match for the country name&lt;/font&gt;&lt;br&gt;                                            code = aryCodes(idx)&lt;br&gt;                                            &lt;font color="#000080"&gt;If&lt;/font&gt; Len(Dir(filePath)) &amp;gt; 0 &lt;font color="#000080"&gt;Then&lt;/font&gt;&lt;br&gt;&lt;font color="#008000"&gt;                                                'Clear the temp file&lt;/font&gt;&lt;br&gt;                                                &lt;font color="#000080"&gt;Kill&lt;/font&gt; filePath&lt;br&gt;                                            &lt;font color="#000080"&gt;End If&lt;br&gt;&lt;/font&gt;                                            &lt;font color="#000080"&gt;Set&lt;/font&gt; cloneShp = mstFlag.Shapes(1).Duplicate&lt;br&gt;                                            cloneShp.Cells(&amp;quot;Prop.Country&amp;quot;).FormulaU = &amp;quot;=&amp;quot;&amp;quot;&amp;quot; &amp;amp; country &amp;amp; &amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;br&gt;                                            cloneShp.Shapes(code).Export filePath&lt;br&gt;                                            cloneShp.Delete&lt;br&gt;                                            &lt;font color="#000080"&gt;If&lt;/font&gt; Len(Dir(filePath)) &amp;gt; 0 &lt;font color="#000080"&gt;Then&lt;/font&gt;&lt;br&gt;&lt;font color="#008000"&gt;                                                'Remove the previous flag&lt;br&gt;                                                'Temporarily unlock the group&lt;/font&gt;&lt;br&gt;                                                subshp.Cells(&amp;quot;LockGroup&amp;quot;).FormulaU = 0&lt;br&gt;                                                imgshp.Delete&lt;br&gt;                                                &lt;font color="#000080"&gt;Set&lt;/font&gt; flagShp = subshp.Import(filePath)&lt;br&gt;                                                flagShp.NameU = &amp;quot;Flag&amp;quot;&lt;br&gt;                                                flagShp.Name = &amp;quot;Flag&amp;quot;&lt;br&gt;&lt;font color="#008000"&gt;                                                'Get the flag aspect ratio&lt;/font&gt;&lt;br&gt;                                                flagWidth = flagShp.Cells(&amp;quot;Width&amp;quot;).ResultIU&lt;br&gt;                                                flagHeight = flagShp.Cells(&amp;quot;Height&amp;quot;).ResultIU&lt;br&gt;                                                flagAspectRatio = flagWidth / flagHeight&lt;br&gt;                                                &lt;font color="#000080"&gt;If&lt;/font&gt; shpAspectRatio &amp;gt; flagAspectRatio &lt;font color="#000080"&gt;Then&lt;/font&gt;&lt;br&gt;&lt;font color="#008000"&gt;                                                    'Maximise height of flag&lt;/font&gt;&lt;br&gt;                                                    flagShp.Cells(&amp;quot;Height&amp;quot;).FormulaU = &amp;quot;=&amp;quot; &amp;amp; shp.NameID &amp;amp; &amp;quot;!Height&amp;quot;&lt;br&gt;                                                    flagShp.Cells(&amp;quot;Width&amp;quot;).FormulaU = &amp;quot;=Height * &amp;quot; &amp;amp; flagAspectRatio&lt;br&gt;                                                &lt;font color="#000080"&gt;Else&lt;/font&gt;&lt;br&gt;&lt;font color="#008000"&gt;                                                    'Maximise width of flag&lt;/font&gt;&lt;br&gt;                                                    flagShp.Cells(&amp;quot;Width&amp;quot;).FormulaU = &amp;quot;=&amp;quot; &amp;amp; subshp.NameID &amp;amp; &amp;quot;!Width&amp;quot;&lt;br&gt;                                                    flagShp.Cells(&amp;quot;Height&amp;quot;).FormulaU = &amp;quot;=Width / &amp;quot; &amp;amp; flagAspectRatio&lt;br&gt;                                                &lt;font color="#000080"&gt;End If&lt;br&gt;&lt;/font&gt;                                                flagShp.Cells(&amp;quot;PinY&amp;quot;).FormulaU = &amp;quot;=&amp;quot; &amp;amp; subshp.NameID &amp;amp; &amp;quot;!Height*0.5&amp;quot;&lt;br&gt;                                                flagShp.Cells(&amp;quot;PinX&amp;quot;).FormulaU = &amp;quot;=&amp;quot; &amp;amp; subshp.NameID &amp;amp; &amp;quot;!Width*0.5&amp;quot;&lt;br&gt;&lt;font color="#008000"&gt;                                                'Reset the group lock&lt;/font&gt;&lt;br&gt;                                                subshp.Cells(&amp;quot;LockGroup&amp;quot;).FormulaU = 1&lt;br&gt;                                                &lt;font color="#000080"&gt;If&lt;/font&gt; Len(Dir(filePath)) &amp;gt; 0 &lt;font color="#000080"&gt;Then&lt;/font&gt;&lt;br&gt;&lt;font color="#008000"&gt;                                                    'Clear the temp file&lt;/font&gt;&lt;br&gt;                                                    &lt;font color="#000080"&gt;Kill&lt;/font&gt; filePath&lt;br&gt;&lt;font color="#000080"&gt;                                                End If&lt;br&gt;                                            End If&lt;br&gt;                                        End If&lt;br&gt;                                    End If&lt;/font&gt;&lt;br&gt;                                    flagExists = True&lt;br&gt;&lt;font color="#000080"&gt;                                    Exit For&lt;br&gt;                                End If&lt;br&gt;                            Next&lt;br&gt;                        End If&lt;br&gt;                    End If&lt;br&gt;                End If&lt;/font&gt;&lt;br&gt;                &lt;font color="#000080"&gt;If &lt;/font&gt;flagExists = &lt;font color="#000080"&gt;True Then&lt;br&gt;&lt;/font&gt;&lt;font color="#008000"&gt;                    'Move on to the next shape in the selection&lt;/font&gt;&lt;br&gt;&lt;font color="#000080"&gt;                    Exit For&lt;br&gt;                End If&lt;/font&gt;&lt;br&gt;            &lt;font color="#000080"&gt;Next&lt;/font&gt; subshp&lt;br&gt;        &lt;font color="#000080"&gt;End If&lt;br&gt;&lt;/font&gt;    &lt;font color="#000080"&gt;Next&lt;/font&gt; shp&lt;br&gt;&lt;font color="#000080"&gt;End Sub&lt;/font&gt; 
&lt;p&gt;&lt;font color="#000080"&gt;Private Function&lt;/font&gt; getLookup(ByVal value &lt;font color="#000080"&gt;As String&lt;/font&gt;, ByVal aryIn &lt;font color="#000080"&gt;As Variant) As Integer&lt;/font&gt;&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; ary() &lt;font color="#000080"&gt;As String&lt;/font&gt;&lt;br&gt;    ary() = aryIn&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; i &lt;font color="#000080"&gt;As Integer&lt;/font&gt;&lt;br&gt;&lt;font color="#000080"&gt;Dim&lt;/font&gt; found &lt;font color="#000080"&gt;As Boolean&lt;/font&gt;&lt;br&gt;    &lt;font color="#000080"&gt;For&lt;/font&gt; i = 0 &lt;font color="#000080"&gt;To &lt;/font&gt;UBound(ary)&lt;br&gt;        &lt;font color="#000080"&gt;If&lt;/font&gt; UCase(value) = UCase(ary(i)) &lt;font color="#000080"&gt;Then&lt;/font&gt;&lt;br&gt;            found = &lt;font color="#000080"&gt;True&lt;/font&gt;&lt;br&gt;&lt;font color="#000080"&gt;            Exit For&lt;br&gt;        End If&lt;br&gt;    Next&lt;/font&gt;&lt;br&gt;    &lt;font color="#000080"&gt;If&lt;/font&gt; found = &lt;font color="#000080"&gt;True Then&lt;br&gt;&lt;/font&gt;        getLookup = i&lt;br&gt;    &lt;font color="#000080"&gt;Else&lt;/font&gt;&lt;br&gt;        getLookup = -1&lt;br&gt;&lt;font color="#000080"&gt;    End If&lt;br&gt;End Function&lt;/font&gt; 
&lt;p&gt;Note : The following web site was invaluable for helping me download the flag image files from the CIA web-site : &lt;a title="http://www.vb-helper.com/howto_download_url_to_file.html" href="http://www.vb-helper.com/howto_download_url_to_file.html"&gt;http://www.vb-helper.com/howto_download_url_to_file.html&lt;/a&gt; 
&lt;p&gt;Interesting related blog: &lt;a title="http://dbwhisperer.blogspot.com/2008/07/getting-geography-data-from-visio.html" href="http://dbwhisperer.blogspot.com/2008/07/getting-geography-data-from-visio.html"&gt;http://dbwhisperer.blogspot.com/2008/07/getting-geography-data-from-visio.html&lt;/a&gt; 
&lt;p&gt;Download files : &lt;a title="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/FlagsOfTheWorld.zip" href="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/FlagsOfTheWorld.zip"&gt;http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/FlagsOfTheWorld.zip&lt;/a&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=3697690708899476393&amp;page=RSS%3a+Flags+of+the+World&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=bvisual.spaces.live.com&amp;amp;GT1=bVisual"&gt;</description><comments>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!521.entry#comment</comments><guid isPermaLink="true">http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!521.entry</guid><pubDate>Sun, 13 Jul 2008 11:33:43 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://bVisual.spaces.live.com/blog/cns!3350D61BC93733A9!521/comments/feed.rss</wfw:commentRss><wfw:comment>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!521.entry#comment</wfw:comment><dcterms:modified>2008-07-13T20:32:41Z</dcterms:modified></item><item><title>Enhancing Visio Data Graphics Text Callouts</title><link>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!483.entry</link><description>&lt;p&gt;Visio 2007 Professional introduced the wonderful Data Graphics feature to display Shape Data in a clear visual way, but it is not clear how you may, for example, change the font of even the simplest Graphic Item type, &lt;em&gt;Text Callouts&lt;/em&gt;.  In this blog, I’ll show you one method that I employ to vary the appearance of Text Callouts.  The same technique can be used for other Graphic Item types, Icon Sets and Data Bars. 
&lt;p&gt;I am using the  the sample &lt;em&gt;IT Asset Management&lt;/em&gt; drawing to demonstrate throughout, which can be found in the Samples Template Category.  In this diagram, the server shapes on the topology page use the &lt;em&gt;Topology 1&lt;/em&gt; Data Graphic, which can be seen in the Data Graphics panel. 
&lt;p&gt;&lt;a href="http://j8ysfq.blu.livefilestore.com/y1p5ml5du9jvOw0lJhq_2Do9Ixw-93ODWGVWmiBXqpkgBueg68hQhjm-IY4zY10HF9qkNmjy3BUSHBs18YV0LqCug?PARTNER=WRITER"&gt;&lt;img title=image style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=398 alt=image src="http://j8ysfq.blu.livefilestore.com/y1pHeOR1b4etja383jXp3GvPc_Br0jqVXhpsaelf2yViiIyeoc5gzUfVq3KLVMKPTIB_HOq-bcU2RQdpDvuXoc7YFJT8_UN9wBo?PARTNER=WRITER" width=606 border=0&gt;&lt;/a&gt; 
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;Microsoft had to introduce a new capability in Visio 2007 in order to get Data Graphics working, namely the ability for a shape instance to hold a reference to a DataGraphic master in addition to its normal master.  So, if you open the Drawing Explorer window, you can see the normal &lt;em&gt;Server&lt;/em&gt; master, in addition to the &lt;em&gt;Topology 1&lt;/em&gt; Data Graphic master.  If you open the &lt;em&gt;Topology 1&lt;/em&gt; master, you can see the full Data Graphic, and you can expand the Master Explorer to show that there are multiple shapes inside it.  These shapes are the ones that you see displayed in a more friendly way in the Edit Data Graphic dialog. 
&lt;p&gt;&lt;a href="http://j8ysfq.blu.livefilestore.com/y1pHeOR1b4etjaMJmUjccQ2EriTFNErlIEgIt6_vwNKk9G9SKHZ0pZCz74odckouSxNMZZGZv1HWUdFTeLn3SO32tcZ7fgQf5SV?PARTNER=WRITER"&gt;&lt;img title=image style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=388 alt=image src="http://j8ysfq.blu.livefilestore.com/y1pHeOR1b4etjYdYUAV8DNp6ZMNhwmmPadx5ha8wAl2wnfuFSRpWVdJ97SDsXu-stHdbA-awzBJW2IBnmaC8ZwZoWpLX4TLUzOK?PARTNER=WRITER" width=604 border=0&gt;&lt;/a&gt; 
&lt;p&gt;However, you may also notice that this particular Data Graphic uses the same &lt;em&gt;Text callout&lt;/em&gt; Graphic Item multiple times.  This is evident if you select Edit Item for &lt;em&gt;Operating System&lt;/em&gt;, &lt;em&gt;CPU (MHz),&lt;/em&gt; &lt;em&gt;Memory (MB)&lt;/em&gt; or &lt;em&gt;IP Address&lt;/em&gt; Data Fields in the Edit Data Graphic dialog.  In fact, you can only tell which Graphic Item master is being used in the Data Graphic master in code, or by opening the ShapeSheet of each of the sub-shapes. 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1p-mAN70zrGh2Lkc9lgLvVIl4YXj6yZtw-DlW5LF3PcVnxhug_5J5CoDK7g0ZgPSI-C6XjsdCHxxu3dRPnVGcJaDR1Tb_HSC40?PARTNER=WRITER"&gt;&lt;img title=image style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=340 alt=image src="http://blufiles.storage.msn.com/y1p-mAN70zrGh2bupk2OiWSOz-CYjf03h_JuWuSfypPgR25Dq73mMVQ7CclD9hPTrnykb-HKYzNMbXIkaOJQMR07yIxVP4dAIP9?PARTNER=WRITER" width=457 border=0&gt;&lt;/a&gt; 
&lt;p&gt;You can see on the Edit Text dialog that you can edit certain properties, but font is not one of them!  SO, how can you edit the font?  Well, you could go around each shape in the diagram, sub-select the shapes and change it that way, or you can create a variation of the &lt;em&gt;Text callout&lt;/em&gt; Graphic Item master. 
&lt;p&gt;In the Drawing Explorer window, select the &lt;em&gt;Text callout&lt;/em&gt; master, then Duplicate on its right mouse menu.  You can then rename the new &lt;em&gt;Text callout.xxx&lt;/em&gt; as whatever you like (I have used &lt;em&gt;Text callout A&lt;/em&gt;). 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1p-mAN70zrGh2vxL63_oz5icbf8GQM9ppLnhHWsAn2XA1EQqkid0OSDR0xoi_Ta9-ikd5gSdRZcd6kwPOrI_CcrlLkvKsok3Ex?PARTNER=WRITER"&gt;&lt;img title=image style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=192 alt=image src="http://blufiles.storage.msn.com/y1p-mAN70zrGh1UPpf3hempwvPb1MgeYY829vQPiuPZos794pKVV7QmzYT9cPvB73JdbvSWpxRegy316xOuH5hJfiho8cF66Zrx?PARTNER=WRITER" width=244 border=0&gt;&lt;/a&gt;     &lt;a href="http://blufiles.storage.msn.com/y1p-mAN70zrGh0arDrUlC_BPyZ-Jg7-dWkH10ChQ0jkqXsPVewrEO7oe1NEU9Fn8Zo74aUTNvMb0NUbQHmn5xuoZmXu4Nng5Gu9?PARTNER=WRITER"&gt;&lt;img title=image style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=150 alt=image src="http://blufiles.storage.msn.com/y1p-mAN70zrGh0Ybxnp4nsAE71T_5rtYivtkBp7zaWh8B1vaSGnAIcTwLYPjC5DJeSFr7qZRs-Txf9-LyQHEhIEDRwHApygzxtO?PARTNER=WRITER" width=227 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Once you have a copy, you can double-click (or use select Edit Master Shape from its right mouse menu).  You will see that the &lt;em&gt;Text callout&lt;/em&gt; master is comprised of two shapes, Sheet.5 (which is the group) and Sheet.6 (a sub-shape of the  group).  The &lt;em&gt;Label&lt;/em&gt; text is part of Sheet.5, whilst the value (&lt;em&gt;Abc&lt;/em&gt;) is part of Sheet.6. 
&lt;p&gt;&lt;a href="http://j8ysfq.blu.livefilestore.com/y1pHeOR1b4etjaE78ZzkiDQM_5J0il7-nLxtw7SQTbqA1bwjCf960QVp-0o38Q4B1q07QkRG6rRGFDKml-wvz3woy25rgAhMCbL?PARTNER=WRITER"&gt;&lt;img title=image style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=284 alt=image src="http://blufiles.storage.msn.com/y1p-mAN70zrGh3GtienD2Hqm8fZUMKLjnbcI4geHUP-ajMFpHg1XYPmTVzHZr0M4aWs3imEVJ7zUlameBnxsMOPVIvYL23U3cCC?PARTNER=WRITER" width=452 border=0&gt;&lt;/a&gt;  
&lt;p&gt;You can now edit the font of either the whole lot by selecting the shape, or you can just do the value by selecting Sheet.6 in the Master Explorer window. 
&lt;p&gt;  &lt;a href="http://blufiles.storage.msn.com/y1p-mAN70zrGh3yooOLIPftcUSjaJkhaLPtKRGwEuy7zS5nGDmpLI-EFn8zRRr9bXirQxbAwiiUmM24S-dF3J0oDRSVrRZ_2msv?PARTNER=WRITER"&gt;&lt;img title=image style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=327 alt=image src="http://blufiles.storage.msn.com/y1p-mAN70zrGh0pAiUjz9B9L_-F3pnJ-Kt1KuWXTKIOaFjj4Y9R7gsaeDlyoIZGytHcKcTRQYialaQvYD7VPrc72ap3C13CFLl6?PARTNER=WRITER" width=452 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Now, you can close the Master Edit window to save the changes. 
&lt;p&gt;Now, when you go to the Edit Data Graphic dialog for &lt;em&gt;Toplogy 1&lt;/em&gt; Data Graphic, and select Edit Item for, say, &lt;em&gt;Operating System&lt;/em&gt;, you will find your new variation, &lt;em&gt;Text callout A&lt;/em&gt;, listed. 
&lt;p&gt;&lt;a href="http://j8ysfq.blu.livefilestore.com/y1pHeOR1b4etjZ_WNQDjXG-s12eJtHcLcta4Dts1zmTK4R8pTWAPwLymDcHu4v3HpiQQRxn9n9mTMnoB5GedvqQtPO6yY1WNKyi?PARTNER=WRITER"&gt;&lt;img title=image style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=362 alt=image src="http://blufiles.storage.msn.com/y1p-mAN70zrGh1QqO1VaqmKz353nJJoeFPAOgs6G9JIiMQXcNP0Z5o5UFR2tnC_Ruz7nDBcvxXl8a_G3OxTWLTn16dXnFG3RtTN?PARTNER=WRITER" width=592 border=0&gt;&lt;/a&gt; 
&lt;p&gt;So, when you select your new variation of &lt;em&gt;Text callout&lt;/em&gt;, all of the shapes that use it will be updated automatically! 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1p-mAN70zrGh3GHEPYsRyWk1Mp5iJBkOZMNy72xgMAcNkXZI-wIm7FjfiyVWVAJ7aK_qb6CVtHjLPF1yz3efSk89UXenO0ah5e?PARTNER=WRITER"&gt;&lt;img title=image style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=482 alt=image src="http://blufiles.storage.msn.com/y1p-mAN70zrGh10gmWgWS7Sm6EvPST_Olw_VPR1wAc6aR3cw7_IL2PMPHO6GWT7bKyuXuaiqUxhhBWrq9sCdt-TddJtciHOsnou?PARTNER=WRITER" width=592 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Q.E.D. 
&lt;p&gt;By the way, there’s more like this in my book …&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=3697690708899476393&amp;page=RSS%3a+Enhancing+Visio+Data+Graphics+Text+Callouts&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=bvisual.spaces.live.com&amp;amp;GT1=bVisual"&gt;</description><comments>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!483.entry#comment</comments><guid isPermaLink="true">http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!483.entry</guid><pubDate>Thu, 19 Jun 2008 08:39:49 GMT</pubDate><slash:comments>3</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://bVisual.spaces.live.com/blog/cns!3350D61BC93733A9!483/comments/feed.rss</wfw:commentRss><wfw:comment>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!483.entry#comment</wfw:comment><dcterms:modified>2008-06-19T08:41:18Z</dcterms:modified></item><item><title>Linking Visio WBS Modeler Diagrams to Project</title><link>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!404.entry</link><description>&lt;p&gt;I have recently been asked if it is possible to update the % Complete data diagrams created with the WBS Modeler Visio 2007 Add-in (&lt;a title="http://www.microsoft.com/downloads/details.aspx?FamilyID=34c28a49-e14c-4a7d-8d49-90061fe08ab4&amp;amp;DisplayLang=en" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=34c28a49-e14c-4a7d-8d49-90061fe08ab4&amp;amp;DisplayLang=en"&gt;http://www.microsoft.com/downloads/details.aspx?FamilyID=34c28a49-e14c-4a7d-8d49-90061fe08ab4&amp;amp;DisplayLang=en&lt;/a&gt;).  Well, it is always possible with custom code, but it is intended that the WBS Modeler diagrams can be refreshed using the Link Data to Shapes feature in Visio 2007 Professional.  I know this because I wrote WBS Modeler, and in this article, I will tell you how. 
&lt;p&gt;Firstly, I will use the Commercial Construction project that is installed with the Visio SDK for this example, which I show an extract from below. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1p5ml5du9jvOyxz15LPWePycZoycvsbSCy8V5E7LPp2w5Opl2oHz5pc5axnRTisFY3zgI_97zx9tmvMOLN1ZBtFA?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=417 alt=image src="http://j8zpeg.blu.livefilestore.com/y1p5ml5du9jvOwCwo8MipF3jSSPBX_gFZ4BUyZWEFWLLtDO-WFVv__pjLzqtwBU2FpWMgkympS-LSgmUQPEmU9SPQ?PARTNER=WRITER" width=602 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Then I created a new WBS Modeler diagram based on the above project. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjbjmynOVAQL3lCM7cz8A2A6fK7YFv9AGkeqk_wSWWAcgzsz35Uw76DT3_qKdHlH8FGUqEyyYsnyMAckApAOF4Ia?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=387 alt=image src="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjZ3Ad4nzF_EKowwqyu0eKiUaemfPei5_sO9QGc4jTpUG_f1Wo73xUeWi5wgjjLZrmkYTqn3OsGA45eJVXs4Ptou?PARTNER=WRITER" width=602 border=0&gt;&lt;/a&gt; 
&lt;p&gt;I simply imported the whole project using the WBS Modeler / Import from Microsoft Office Project menu action. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjZs-boPkx7oOuRBIcRm07L1qKPJNeW3sz1rjd9HETBngeAvSmx82Ntq2piDXO_jKNKaIOXubnxstmFXpgc_vpps?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=421 alt=image src="http://j8zpeg.blu.livefilestore.com/y1p5ml5du9jvOzxYrST7bTdqq0MrxbzkujA2nhIzFUqWyK_nVRpOWr4IG79MqWYLdJcrMZ6xDvbtSrudRX-7DbALQ?PARTNER=WRITER" width=606 border=0&gt;&lt;/a&gt; 
&lt;p&gt;The Element shapes are color coded according to their Outline Level by default, and they are labeled with their &lt;em&gt;Outline Number&lt;/em&gt; and a truncated version of the &lt;em&gt;Element Name&lt;/em&gt; shape data.  Notice that the Shape Data window shows more of the Project data fields than is displayed on the shape. 
&lt;p&gt;NB If you do see all of these Shape Data rows, then click on the page and ensure that the page &lt;em&gt;Hide extra Project properties&lt;/em&gt; is set to False in the Shape Data window. 
&lt;p&gt;In this particular sample project, there are no costs, nor are there any non-zero % Complete values, so I'll change some of these in the original project, then update the Visio diagram. 
&lt;p&gt;Therefore, I revealed the Unique ID, % Complete and Cost fields in Project. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjbHCAw_cSbw_pzelxaqzx6LXbMZLMBDihsn-XB42K_fEzAPLcoo04aoNNWz3omoXDjdLdQGTn6uiEAbH1v4__za?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=363 alt=image src="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etja5-i38jSVmUmE8h_Ov6hdu9bHuZmEAJWJXPt5ZmSErda0O-ZU8xKfCRJ7eIk_j_6y5m2r_yu7pE6T9X3bODyIH?PARTNER=WRITER" width=604 border=0&gt;&lt;/a&gt; 
&lt;p&gt;I then exported the Project tasks to Microsoft Excel using File / SaveAs and Selected Data in the Project Export Wizard. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjaZ3EHfxxKKXiyh_8zVxoC46wGwomU-rPIUQnP9v-M82vKlDMY6KwN_dN_qTVHCavBNOS6H_P1Az3l30hQq5ziK?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=295 alt=image src="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjZszl4nP2bSIEgdEf_XkmTp5ffuFkNFxPFRE4IpVrN16DYsobdv8M5tfPl0Os39k0YfTP6jv_zJmkPAMw-3QXrc?PARTNER=WRITER" width=605 border=0&gt;&lt;/a&gt; 
&lt;p&gt;You then need to select the &lt;em&gt;Unique ID&lt;/em&gt; and any other fields that you want to export. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1p5ml5du9jvOyc56L_YbGylDiKAA4w9KOPfPxbqXVCKzB64AqA-uBKfAxI5fwkAG8RM9Ifi30ZNGA78zSLWUxp_w?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=375 alt=image src="http://j8zpeg.blu.livefilestore.com/y1p5ml5du9jvOylrYHXbnTAr4AYjpqRtb1cHZPdYTpadh2HEWrDpUT-B1ND2vJllerrnrtJVx7XSma3yv4oxT2XHw?PARTNER=WRITER" width=601 border=0&gt;&lt;/a&gt; 
&lt;p&gt;You can optionally save the Map for future use, but you should end up with an Excel spreadsheet that contains the data that you requested. 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn6izCirrMRFhpizW0fa1Vu6nr9QM2dj09r184nRBGviiT7pPXYXg_dvzAbAnRkRDEA?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=324 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn6n_YAUdaaDne3bIs9F8X5xEaOamsPceXvIw5olPfGG6mlcbF_4FL7yVIKttqUAyqs?PARTNER=WRITER" width=398 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Then, in Visio 2007 Professional, you can click Data / Link Data to Shapes and select the Excel workbook that you just created.  There should be just one region, &lt;em&gt;Task_Table1$&lt;/em&gt;, and you should ensure that the &lt;em&gt;Unique_ID&lt;/em&gt; column is checked. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1p5ml5du9jvOz5Dq8u94OOM1sVDooPLmx-B_QTMzQ1iueo1g0j3Cb_risH0X7rfe2mZp_5-rlrOoGUvOqoEX8vNA?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=272 alt=image src="http://blu1.storage.msn.com/y1p-mAN70zrGh2EvuVHVMEnM0mMre6Ku2Ks7ZfboscnvQpD_0B-AZS40Bhsedegondd6urAdqRV3bCx1MMAe1gxX43nhdVa5ZMf?PARTNER=WRITER" width=396 border=0&gt;&lt;/a&gt; 
&lt;p&gt;When you click Finish, the Excel data is copied into the Visio document as External Data.  You must now ensure that the column labels match those on the Element shapes by opening the Column Settings dialog from the right-mouse menu of the External Data window. So, &lt;em&gt;Unique_ID&lt;/em&gt; becomes &lt;em&gt;Unique ID&lt;/em&gt; and &lt;em&gt;Percent_Complete&lt;/em&gt; becomes &lt;em&gt;% Complete&lt;/em&gt;.  This will ensure that the data is copied into existing Shape Data rows rather than creating new ones. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjaUpCdqk3V06wukr69ke2nE20AvVOt2DT8SgGMVDSxRURTzNgGd9NOiydUdr_ObAS3E8gOQf2yZxldcZmxeVI_J?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=218 alt=image src="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjaGU5LHEiXAlAbU-MSqTRlQZtM1CLSZd4WT07DtjKKsKbAjmAObXmCYyzeIL_5SotY3Jkc6ccMgukPb7u43_vuh?PARTNER=WRITER" width=606 border=0&gt;&lt;/a&gt; 
&lt;p&gt;In addition, I changed the Data Type for the Cost field to String because my original Element shape is expecting a string. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjYGZ7kuZD860Li5cLw43P4sEaIu-bN2Rj5igRie5UPfcspqz7cSFLmM7xdxz5-DvoVQ569bAom5K2btQI9giHX_?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=182 alt=image src="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjYcHnXK0p3GXvQF6vpf-g45k_IvwSxj1_Id5DWzMFYo8ogXxS7UNCYAGWoOfla2p6pm7kWigHDQ3jA0fFkbeCJs?PARTNER=WRITER" width=606 border=0&gt;&lt;/a&gt; 
&lt;p&gt;You can then choose &lt;em&gt;Automatically Link&lt;/em&gt; from the right-mouse menu of the External Data window, and use the &lt;em&gt;All shapes on this page&lt;/em&gt; option.  Finally, you must ensure that the Data Column &lt;em&gt;Unique ID&lt;/em&gt; equals the Shape Field &lt;em&gt;Unique ID&lt;/em&gt;. 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn4lU7inNXlfBVG1XGluhZmUFEw0HG7dwVymFaqz7j6wvzArQMVOjnT_QpXCOVHqo3w?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=300 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn6bOLsYGtzSH5AhzAGuNYp9nYuScjMtCDmpxZQst65WN1zeTXvCHzfP-1_cQQyCzj4?PARTNER=WRITER" width=392 border=0&gt;&lt;/a&gt; 
&lt;p&gt;When the links have been created, you will probably think that something has gone wrong because everything has turned black. 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn7CZapMuNP3kb34QfxQ-lUDnYaJ_lCkIPnTOkofRt1BVGzcA4K6ocYLQcgzvCiEX-8?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=316 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn76rAoI0JTHomXaaqpaPwI4be3f3WDUOtQZtENtIv7kv6pUvgk8XZs4IMqKl_VIQLo?PARTNER=WRITER" width=391 border=0&gt;&lt;/a&gt; 
&lt;p&gt;However, this is normal because Visio has automatically assigned a Data Graphic to all the shapes, so all you need to do is edit it.  In this example, I simply deleted the two text fields that Visio had automatically created, and then added a new Data Bars for the &lt;em&gt;% Complete&lt;/em&gt; and &lt;em&gt;Cost&lt;/em&gt; fields, and Color By Value for the &lt;em&gt;Parent Element&lt;/em&gt;. 
&lt;p&gt;I entered the Custom Formula={% Complete}*100 so that the numbers would be between 0 and 100.  You can enter these formulae by selecting More Fields at the bottom of the Data Fields drop-down list on the New Data Bar dialog. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1p5ml5du9jvOyODR21zFCxl1tVs-NZpY2B7SQJnUjOYnUBNKefqaD-Mk0EBNRkQqILI8JcGtRmV0XsvehxRzZVFw?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=431 alt=image src="http://blu1.storage.msn.com/y1p-mAN70zrGh017x3f5BFAjK29znmdB6vW9QRJKwVcPKYR7Bu0AYsJme9FFkGnGJizWouS62Vs-H7ad-KBTNQx-dDcDEQhtI1n?PARTNER=WRITER" width=595 border=0&gt;&lt;/a&gt; 
&lt;p&gt;I also edited the Label text and selected the position to be Center/Bottom Edge. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjZI7TG4usIewk3uxanZeuGU01GCvwXq9QjJkZ56civGVTHKyPDokf1eEzTMAeeGHI-Dt_LGXBMapv3KNrjZQbgC?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=403 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn40UfzrfbUBmS4UK4Ja5Z2mTjca7toalztB6QtEsgbl5-pGgPssNKxg7RFIUxBTRp4?PARTNER=WRITER" width=595 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Although I set the &lt;em&gt;Cost&lt;/em&gt; property as String for the import, Visio is still able to treat the contents as a number for the Data Graphics, so I thought a Thermometer Data Bar would be interesting.  Note that I set the Maximum Value to more than the known data values.  (See my Visio Conference blog for code on how to automatically update maxima and minima values). 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1p5ml5du9jvOyTdSQ4pzCLTfHgBN-v_Cll_hIoGihUMS0LOX5p_S3Ycc1Z8S44smRnNG1VBTbwBxXsvXnHbaFzJQ?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=404 alt=image src="http://j8zpeg.blu.livefilestore.com/y1p5ml5du9jvOwtrfswXPuGWxAD5a3Bu-Ix9sTWrex_myzKDeYV6TXLHt_-h9UVIA33IcaBrkW61-ZYmOYwQkmnpA?PARTNER=WRITER" width=604 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Finally, I decided to use Color By Value on the &lt;em&gt;Parent Element&lt;/em&gt; property rather than on the &lt;em&gt;Outline Level&lt;/em&gt; one ... just to make the diagram more interesting. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjay3tcC1VQ84nAzda4zODtxhhq4s6ZQftVihZy2zXK0bwtRtIH5DhrtVJ3bQxFystlCG1B7iSeOWXOMvrsugpw0?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=429 alt=image src="http://blu1.storage.msn.com/y1p-mAN70zrGh2C_DsRkfpgr6KR1wObKlhmseo5UHcaoGwZ4J6iRj87RS8K7NLck-yFM7YdIE60Bp97e2JhZW0sqSg2vJsUin_8?PARTNER=WRITER" width=600 border=0&gt;&lt;/a&gt; 
&lt;p&gt;When all of this is applied, then you will hopefully see how much more understandable the data is when Link Data to Shapes and Data Graphics are combined in Visio 2007 Professional. 
&lt;p&gt;&lt;a href="http://blu1.storage.msn.com/y1p-mAN70zrGh0pheCoH50p4f1gHbeR-AWM5VerZcO6c5uKjdQxzkunsG8c8l06HT9C0y33mLKG99_qkieq81baC3_c2gzJYIq_?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=575 alt=image src="http://blu1.storage.msn.com/y1p-mAN70zrGh2i47iK2wyxBzSArmoWSL0yb0RbkHLLBmucbVNeTpw-1JDLEzt5iCYnuXaU8PijNY0__06j4aH17a5dXmHLolRQ?PARTNER=WRITER" width=596 border=0&gt;&lt;/a&gt; 
&lt;p&gt;So,the overall effect is a linked WBS Modeler diagram that can be refreshed whenever the data is published into the Excel workbook from Project. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjZ4_gv1aFek3U1ZSBQEzh9HV8p7AlL1EAcAEr7jtUiD3j2jSC6GS-XWdTjCKRee4ksldaF-gi_vkBafwLeq1SCD?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=413 alt=image src="http://blu1.storage.msn.com/y1p-mAN70zrGh3ypZilQvGXcI759owyLaEquf1sXAt0xxSZFIJPIhUBq3wnX8jb2j_-8HqEjHUwpSc6rS3dwkItVqoJKPeRBP6g?PARTNER=WRITER" width=596 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Of course, any Visio diagram that utilises Data Graphics is much enhanced by a legends for the linked recordsets, Color By Value and Icon Sets.  However, this is not available out-of-the-box, so you will have to trial (then hopefully buy) my own DataLegends add-in (&lt;a title="http://www.bvisual.net/Products/DataLegends.aspx" href="http://www.bvisual.net/Products/DataLegends.aspx"&gt;http://www.bvisual.net/Products/DataLegends.aspx&lt;/a&gt;) 
&lt;p&gt;The files above are available for download at &lt;a title="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/CommercialConstruction.zip" href="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/CommercialConstruction.zip"&gt;http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/CommercialConstruction.zip&lt;/a&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=3697690708899476393&amp;page=RSS%3a+Linking+Visio+WBS+Modeler+Diagrams+to+Project&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=bvisual.spaces.live.com&amp;amp;GT1=bVisual"&gt;</description><comments>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!404.entry#comment</comments><guid isPermaLink="true">http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!404.entry</guid><pubDate>Thu, 24 Apr 2008 11:34:02 GMT</pubDate><slash:comments>5</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://bVisual.spaces.live.com/blog/cns!3350D61BC93733A9!404/comments/feed.rss</wfw:commentRss><wfw:comment>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!404.entry#comment</wfw:comment><dcterms:modified>2008-06-17T13:57:46Z</dcterms:modified></item><item><title>Setting Visio Shape Cell Values By Connections</title><link>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!347.entry</link><description>&lt;p&gt;A recent newsgroup poster asked me to explain how to set the line color and weight of a connector according to the shapes it is connected to.  So, in this article, I have tried to explain one method of achieving this with minimal external coding. 
&lt;p&gt;In this example, I have created a rectangle shape that has a single Shape Data row, MyData, which has a fixed list of values, A;B;C. 
&lt;p&gt;The connector shape has been modified to trigger an event whenever a connection is made or unmade.  If the user successfully connects two rectangles with the same MyData value, then the line (weight and color) of the connector shape is amended to match the rectangle shapes. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1p5ml5du9jvOx0VkU4JkGgUv9DIarjm2JkSTipQlvvnR66lJAGUrc59GJlGXkFBFq_spvbNBZsqJ9674AfL4IDDA?PARTNER=WRITER"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px" height=193 alt=image src="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjYBfghPHA9TSuMyEknyziVRMpZilh2w1yGcUkaDms_YXI3ZVNsrdytoStLF8aQBe_QQDbNSciVmw73BlyuiRj45?PARTNER=WRITER" width=610 border=0&gt;&lt;/a&gt; 
&lt;p&gt;The diagram below attempts to explain the relationships between the cells in the rectangle, connector and page. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1p5ml5du9jvOy052dbTkHMARRgu2pZGUFDESzv_7dVwIgf-qlXtxWIeV_oAN0amSH3os7xPIlg4aWysfpc25S9uQ?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=268 alt=image src="http://j8zpeg.blu.livefilestore.com/y1p5ml5du9jvOwevH2G2Sfswtk2kQKwsrPhbhFmdXl0RuusVuvKdKwhguKTcZ30aqPUItqVxzelaoLEMIQY4Fb2Zg?PARTNER=WRITER" width=608 border=0&gt;&lt;/a&gt; 
&lt;p&gt;The red arrows indicate the values updated by the VBA code; the green arrows indicate the values referenced from the page shapesheet, and the blue arrows indicate the values referenced within the same shapesheet. 
&lt;p&gt;
&lt;h2&gt;Page&lt;/h2&gt;
&lt;p&gt;I modified the page shapesheet to have three new User-defined rows in order to have a centralised list of possible data values, and the corresponding line weights and colors for each value.  This is done with a simple semi-colon separated list, which could have been updated from an external data source. 
&lt;p&gt;&lt;em&gt;User.MyDataList&lt;/em&gt;=&amp;quot;A;B;C&amp;quot; 
&lt;p&gt;&lt;em&gt;User.MyLineWeights&lt;/em&gt;=&amp;quot;1pt;2pt;3pt&amp;quot; 
&lt;p&gt;&lt;em&gt;User.MyLineColors&lt;/em&gt;=&amp;quot;RGB(255,0,0);RGB(0,255,0);RGB(0,0,255)&amp;quot; 
&lt;p&gt;In fact, these page cells could be inserted into the Master page of both the Rectangle and Connector shape (as in the sample diagram available below) and the act of dropping either master onto a new page will have the effect of duplicating these cells in the page shapesheet. 
&lt;h2&gt;Rectangle&lt;/h2&gt;
&lt;p&gt;Then I modified a rectangle to have a new Shape Data row (Prop.MyData), where the format cell referenced the page User.MyDataList cell. 
&lt;p&gt;&lt;em&gt;Prop.MyData.Format&lt;/em&gt;=ThePage!User.MyDataList 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etja4uvftBYiN9kfFX_C0cOXuzXiJ_nVP7QkMzDVUo7-N6TZfl-Qbsg54xeWRJd4oLKMXEsYb4zsivYsGuojm9r1-?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=41 alt=image src="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjbI_vZ8LNgdgnCObf9Dps5k0IbW4mIU2BY4MkhOd6gTGYxblKuA6jpU-qOOpjm906BeiuuO3CCgh1oHIIN4slst?PARTNER=WRITER" width=602 border=0&gt;&lt;/a&gt; 
&lt;p&gt;The line weight and color of the rectangle is changed with the following formulae: 
&lt;p&gt;&lt;em&gt;LineWeight&lt;/em&gt;=GUARD(INDEX(LOOKUP(Prop.MyData,Prop.MyData.Format),ThePage!User.MyLineWeights)) 
&lt;p&gt;&lt;em&gt;LineColor&lt;/em&gt;=GUARD(INDEX(LOOKUP(Prop.MyData,Prop.MyData.Format),ThePage!User.MyLineColors)) 
&lt;h2&gt;Dynamic Connector&lt;/h2&gt;
&lt;p&gt;Now, in order to get the connector shape to fire an event whenever the connector shape is connected or disconnected, it is necessary to call a bit of code, ConnectIT, whenever the value in the BegTrigger or EndTrigger changes.  These cells are automatically updated whenever a connect or disconnect is done. 
&lt;p&gt;&lt;em&gt;User.ConnectITTrigger&lt;/em&gt;=DEPENDSON(BegTrigger,EndTrigger)+CALLTHIS(&amp;quot;ConnectIT&amp;quot;,&amp;quot;&amp;quot;) 
&lt;p&gt;&lt;em&gt;User.BegIdx&lt;/em&gt;=0 
&lt;p&gt;&lt;em&gt;User.EndIdx&lt;/em&gt;=0 
&lt;p&gt;I amended the LineWeight and LineColor formulae to respond to values in the User.BegIdx and User.EndIdx cells. 
&lt;p&gt;&lt;em&gt;LineWeight&lt;/em&gt;=THEMEGUARD(&lt;strong&gt;IF(AND(User.BegIdx=User.EndIdx,User.BegIdx&amp;gt;0,ISERRVALUE(BeginX)=FALSE,ISERRVALUE(EndX)=FALSE),INDEX(User.BegIdx,ThePage!User.MyLineWeights),&lt;/strong&gt;IF(CELLISTHEMED(FALSE),THEME(&amp;quot;ConnectorWeight&amp;quot;),SETATREFEXPR(THEME(&amp;quot;ConnectorWeight&amp;quot;))))&lt;strong&gt;)&lt;/strong&gt; 
&lt;p&gt;&lt;em&gt;LineColor&lt;/em&gt;=THEMEGUARD(&lt;strong&gt;IF(AND(User.BegIdx=User.EndIdx,User.BegIdx&amp;gt;0,ISERRVALUE(BeginX)=FALSE,ISERRVALUE(EndX)=FALSE),INDEX(User.BegIdx,ThePage!User.MyLineColors),&lt;/strong&gt;IF(CELLISTHEMED(FALSE),SETATREFEXPR(THEME(&amp;quot;ConnectorColor&amp;quot;)),SETATREFEXPR(0)))) 
&lt;p&gt;The bold characters are those bits that I added into the existing LineWeight and LineColor formulae, in order to check that the index of the values of the rectangle shapes at either end match each other.  If they do, then the line is changed too. 
&lt;p&gt;The ISERRVALUE(BeginX)=FALSE and ISERRVALUE(EndX)=FALSE part trap the changes due to either rectangle from being deleted. 
&lt;h2&gt;VBA Code&lt;/h2&gt;
&lt;p&gt;Whenever the code is called, it clears the values in the User.BegIdx and User.EndIdx cells, then sets a formula to return the index of the value in the connected rectangle shapes, if they exist. 
&lt;p&gt;The following subroutine was added to a new module in the VBA project of the document: 
&lt;p&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;Public Sub&lt;/font&gt; ConnectIT(&lt;font color="#0000ff"&gt;ByVal&lt;/font&gt; shp &lt;font color="#0000ff"&gt;As&lt;/font&gt; Visio.Shape)&lt;/font&gt; 
&lt;blockquote&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;If &lt;/font&gt;Visio.Application.IsUndoingOrRedoing &lt;font color="#0000ff"&gt;Then&lt;/font&gt;&lt;br&gt;    &lt;font color="#0000ff"&gt;Exit Sub&lt;/font&gt;&lt;br&gt;&lt;font color="#0000ff"&gt;End If&lt;/font&gt;&lt;br&gt;&lt;font color="#0000ff"&gt;Dim&lt;/font&gt; cnx &lt;font color="#0000ff"&gt;As&lt;/font&gt; Visio.Connect&lt;br&gt;shp.Cells(&amp;quot;User.BegIdx&amp;quot;).Formula = &amp;quot;0&amp;quot;&lt;br&gt;shp.Cells(&amp;quot;User.EndIdx&amp;quot;).Formula = &amp;quot;0&amp;quot;&lt;br&gt;&lt;font color="#0000ff"&gt;For Each&lt;/font&gt; cnx &lt;font color="#0000ff"&gt;In&lt;/font&gt; shp.Connects&lt;br&gt;    If cnx.ToSheet.CellExists(&amp;quot;Prop.MyData&amp;quot;, Visio.visExistsAnywhere) &lt;font color="#0000ff"&gt;Then&lt;/font&gt;&lt;br&gt;        &lt;font color="#0000ff"&gt;If&lt;/font&gt; cnx.FromCell.Name = &amp;quot;BeginX&amp;quot; &lt;font color="#0000ff"&gt;Then&lt;/font&gt;&lt;br&gt;            shp.Cells(&amp;quot;User.BegIdx&amp;quot;).Formula = _&lt;br&gt;                &amp;quot;=LOOKUP(Sheet.&amp;quot; &amp;amp; cnx.ToSheet.ID &amp;amp; _&lt;br&gt;                &amp;quot;!Prop.MyData,ThePage!User.MyDataList)&amp;quot;&lt;br&gt;        &lt;font color="#0000ff"&gt;ElseIf&lt;/font&gt; cnx.FromCell.Name = &amp;quot;EndX&amp;quot; &lt;font color="#0000ff"&gt;Then&lt;/font&gt;&lt;br&gt;            shp.Cells(&amp;quot;User.EndIdx&amp;quot;).Formula = _&lt;br&gt;                &amp;quot;=LOOKUP(Sheet.&amp;quot; &amp;amp; cnx.ToSheet.ID &amp;amp; _&lt;br&gt;                &amp;quot;!Prop.MyData,ThePage!User.MyDataList)&amp;quot;&lt;br&gt;        &lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;End If&lt;br&gt;&lt;/font&gt;    &lt;font color="#0000ff"&gt;End If&lt;/font&gt;&lt;br&gt;&lt;font color="#0000ff"&gt;Next&lt;/font&gt;&lt;/font&gt;&lt;/blockquote&gt;
&lt;p align=left&gt;&lt;font face="Courier New" color="#0000ff"&gt;End Sub&lt;/font&gt; 
&lt;p&gt;Consequently, the connector shape responds to connections, disconnections and data changes in the connected rectangle shapes. 
&lt;p&gt;You can download the sample drawing here: &lt;a href="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/ConnectTrigger.vsd"&gt;http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/ConnectTrigger.vsd&lt;/a&gt; or &lt;a href="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/ConnectTrigger.zip"&gt;http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/ConnectTrigger.zip&lt;/a&gt;&lt;a href="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/ConnectTrigger.vsd"&gt;&lt;/a&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=3697690708899476393&amp;page=RSS%3a+Setting+Visio+Shape+Cell+Values+By+Connections&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=bvisual.spaces.live.com&amp;amp;GT1=bVisual"&gt;</description><comments>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!347.entry#comment</comments><guid isPermaLink="true">http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!347.entry</guid><pubDate>Sun, 20 Apr 2008 21:30:36 GMT</pubDate><slash:comments>1</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://bVisual.spaces.live.com/blog/cns!3350D61BC93733A9!347/comments/feed.rss</wfw:commentRss><wfw:comment>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!347.entry#comment</wfw:comment><dcterms:modified>2008-06-17T13:58:35Z</dcterms:modified></item><item><title>UK Counties and Boroughs Map Shapes for Visio</title><link>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!330.entry</link><description>&lt;p&gt;My friend and colleague, Chris Roth, has made lots of maps available in Visio, his latest being Germany ( &lt;a title="http://www.visguy.com/2008/03/01/map-of-germany/" href="http://www.visguy.com/2008/03/01/map-of-germany/"&gt;http://www.visguy.com/2008/03/01/map-of-germany/&lt;/a&gt; ).  Well, we Brits hate being outdone by a German-American, so I have decided to make my UK Map shapes for Visio publicly available at  &lt;a title="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/UK%20Geography%20Structure.vsd" href="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/UK Geography Structure.vsd"&gt;http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/UK%20Geography%20Structure.vsd&lt;/a&gt; . 
&lt;p&gt;I created the UK map several years ago by converting from PDF to SVG to Visio, and each of the counties and boroughs have a single rectangular Master, Admin Area.  I used code to replace the rectangle geometry with the actual shape geometry.  This means that, although they are all different, they actually have the same Master, thus making it easier to propagate any changes, such as Shape Data rows. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjaJqHumVPwHLkEIzheR8oqsgNmw5-w9BEPO7scGXwgesDKscfAxMkBMC8NPbkGd95_2WI9UIGyDwXlB2kbS-P-7?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=454 alt=image src="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjaFgKo3zDUj2kP2BRG82HyXxbdtALkiqNHR953JhzbY2yak9GmKFwPGoKwJ09XnBqU-5aZ8Sq7A8ngpsHj7inyy?PARTNER=WRITER" width=609 border=0&gt;&lt;/a&gt; 
&lt;p&gt;The download is a multi-page document of over 3mb, so be warned, and it also includes a chart of the breakdown of the UK Administrative Areas. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjb_Q_av3M2HEs3-6YpmUI673id0VWFvZde_u8tPgN6DRywF0IJnMAeldUPV5x2zFleRjGsPaFs21SuXNRkohHcc?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=430 alt=image src="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjYPP2LMg-zhGPcvkxidqg34zpV5sNyR0bAlkcDoen5LQCS8asb3spvX-WnVnQ0wmydEFMYGoeKJgXU80vWbOlqz?PARTNER=WRITER" width=610 border=0&gt;&lt;/a&gt; 
&lt;p&gt;The Admin Area (and County) shapes are linked to the Excel spreadsheet (&lt;a title="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/UK%20Counties%20and%20Unitary%20Authorities.xlsx" href="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/UK Counties and Unitary Authorities.xlsx"&gt;http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/UK%20Counties%20and%20Unitary%20Authorities.xlsx&lt;/a&gt;), UK Counties and Unitary Authorities.xlsx, which contains columns of data about each area, and provides an hyperlink  Notice the formula to concatenate two strings): 
&lt;p&gt;=HYPERLINK(&amp;quot;&lt;a href="http://en.wikipedia.org/wiki/&amp;quot;"&gt;http://en.wikipedia.org/wiki/&amp;quot;&lt;/a&gt; &amp;amp; SUBSTITUTE(C2,&amp;quot; &amp;quot;,&amp;quot;_&amp;quot;)) 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjasHK1qv-9efQBuPO1C2NHU4tbrBa9g0t7Ndc2F5i9WpkE-h9RNuYZoCUzlH3SniS3xN6YLwYAiaRsyjsfHBk9X?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=137 alt=image src="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjaXrsuogusn2U6t4QaEcESwc4jnhNt0TZwLg4_kR2Gj63fxBFU2St7xVVQ8n_xfcknm_0yZKts0Td5OdcXdug8d?PARTNER=WRITER" width=607 border=0&gt;&lt;/a&gt; 
&lt;p&gt;I found out that the Visio 2007 Professional LinkData to Shapes function automatically  thinks that values with &amp;quot;xxx:&amp;quot; at the start are hyperlinks, so I had to uncheck the Hyperlink setting for the Information column.  (Interestingly, &amp;quot;Code:xxxx&amp;quot; opens op Lutz Roeder's Reflector app on my PC!) 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjaUJE-i_5FCfXQvo8yZg2cSAfFSoQkIYeIl--prhjx0msAtCBvPEM2qY8-gKX15aoVQ86qD_fk3YEIRTfsz-dt_?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=378 alt=image src="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjZRdiVDJa2ojBX4CTgsVkJkB2TvOhJtVPdJI4jMut_ghCb02MxbJj2BWpb0-zJiGkeBzKDvEkgI5M2JR3XGT-U3?PARTNER=WRITER" width=610 border=0&gt;&lt;/a&gt; 
&lt;p&gt;After making this change, I was able to Automatically Link the data to the shapes where Name = Name, and end up with a hyperlink that points to the Wikipedia for the region. 
&lt;p&gt;&lt;a href="http://blu1.storage.msn.com/y1p-mAN70zrGh0dDtxwQgBBlDpImUhluboE1cHF4ETgwdLvH8o6yYy-yaplXWPq9EP9Vtgz7W-CSkrsoMlnwj7CJ9nSL0M_wXWw?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=272 alt=image src="http://blu1.storage.msn.com/y1p-mAN70zrGh10xrowS7398CeZDFiWEpZK6Hlx1tNTQcokLKO5Nxb5XoefZaucXwXwWZR7gCA_sY8_4UryItPZyuQicVfO167p?PARTNER=WRITER" width=309 border=0&gt;&lt;/a&gt;  
&lt;p&gt;NB.  I was going to use the Visio 2007 Professional Color By Value to automatically fill the regions, but I discovered that there is currently a 100 discrete value limit...so, I have used the Space Plan Color By Value legends - that does not have the limit!  Maybe next version... 
&lt;p&gt;Enjoy!&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=3697690708899476393&amp;page=RSS%3a+UK+Counties+and+Boroughs+Map+Shapes+for+Visio&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=bvisual.spaces.live.com&amp;amp;GT1=bVisual"&gt;</description><comments>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!330.entry#comment</comments><guid isPermaLink="true">http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!330.entry</guid><pubDate>Fri, 04 Apr 2008 10:26:06 GMT</pubDate><slash:comments>1</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://bVisual.spaces.live.com/blog/cns!3350D61BC93733A9!330/comments/feed.rss</wfw:commentRss><wfw:comment>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!330.entry#comment</wfw:comment><dcterms:modified>2008-06-17T14:00:29Z</dcterms:modified></item><item><title>Using Fill Patterns with DataGraphic Color By Value</title><link>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!313.entry</link><description>&lt;p&gt;Microsoft Office Visio 2007 Professional provides the ability to color shapes by different values in selected cells.  This is great, but just how many color variations can your eyes detect?  If you have lots of different values, then the color by value automatically produced colors can look too similar to be able to distinguish them apart. In this article, I propose a method of automatically assigning different fill patterns to similar colors so that they can be visually separated. 
&lt;p&gt;First, we must try to understand how the color by value works. In the following example based on a large number of uniquely named departments, I wish to be able to distinguish the spaces assigned to each one on a floor plan.  I have just shown the color assignments for the first 20 departments (automatically sorted alphabetically) created with a Color By Value Data Graphic item for the Department shape data values. 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn5kvKBo4Xw3JQhSK3YeZA3EJfSeMWnFsW6KfzttBqqxQNb6stA0v1zuHKtdkuB80WY?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=111 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn4AHf6rT210ziCpBNPjvnPzt-WZAAuSAwDqcLJFZUIHcrr4dZ4wIE3GfhY1NYEstQ8?PARTNER=WRITER" width=244 border=0&gt;&lt;/a&gt; &lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn6LTN5-pUuKa6hGNWV8E-6DwRbS7XWgf2YYjeotStvc62onUzhWRSCD2RYkvn0IMR4?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=111 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn5Qz58WbwhyehCMJZhzqgBgP8fPGzopCgHc4MuiNySI4GYnNew8CsY5TQbvxc2p9hI?PARTNER=WRITER" width=244 border=0&gt;&lt;/a&gt; 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn6x_mXm4bEIwoEkKud1M3arP8ABHaZZ3ExChK_Cp_nF775hQh1H6LLZaoVpQLYbvuI?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=111 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn5g9s-9AW7u2VCFrQI2vgT55j8sazArCdHtMSK5QWy5GVnVnJh_OYDd-oktbCuFlJs?PARTNER=WRITER" width=244 border=0&gt;&lt;/a&gt; &lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn4jyqqe-33xgj5PZLii2Vi4VYjexzocyj9htC0obLpf5xQDviGN1oCejwxV05jnPus?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=111 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn7IyoA5mILB77SG8x_b3RqxY3ExBK-m1al5IL6gqMg_vYIYDhk-cU3yA6iFOKWgZoQ?PARTNER=WRITER" width=244 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Notice how the color assignments have started again from the Red for Dept 23?  So, we have reached the limit of automatically assigned colors.  Of course, we could decide to blend our own colors using the color picker, and there are a possible 16,777,216 different color combinations using the RGB or HSL notation, but just how many variations can the human eye perceive? 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn52o4hDySwyeSkISSV8kHs02h1ZPQUwccQMWEUPZxS5RT5osA8BqnSRxIomufvLC6M?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=244 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn4y0zQEtnLAr9W6AyX4C7vxCCsOUXGSV96Y4TBS_pJwAcKGE-pRgi9pRw9_YWQI2OM?PARTNER=WRITER" width=229 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Now, the Data Graphic Color By Value formulae are added to an automatically created User.visDGCBVFill cell in the ShapeSheet of the Data Graphic master, and, therefore to all shapes that use it. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1p5ml5du9jvOxQbFRXGRArevbplvikjm-jKxE2SOxuG3cmfai58gWPV9QVXg7JUra_k03qOw-KkOAoFne8oKg1hw?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=69 alt=image src="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etja2swIRZfOCXkeSdMcd1t-3eOfMEky8K6e9iuPdbPlhxdQsPtanCNTkCq0DYq-2tRbRr5uJp7r8sVzbbXMFocef?PARTNER=WRITER" width=606 border=0&gt;&lt;/a&gt; 
&lt;p&gt;In fact, if the shape is a group, then an almost identical formula is added to the sub shapes too, except that they refer to the cell value in the group shape.  Thus Prop.Department would become Sheet.5!Prop.Department (or whatever the sheet ID is). 
&lt;p&gt;N.B.  If you intend to use Data Graphics with instances of a Master, then it is probably worthwhile making it into a group at the start, since any other Data Graphic items (Text Callouts, Data Bars and Icon Sets) will automatically convert the instances into groups.  
&lt;p&gt;The color of the background fill (FillBkgnd) is read from the result of User.visDGCBVFill and the foreground fill (FillForegnd) is a TINT of the back ground fill. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjbr9dtO4W5V4bQXldg6YLKGDoK1hPEmgER2SzcsXl9e3wn5IKk5M9o6GaCo8uhOZg1_1EqDCZ_NX3_6sEyi-ENH?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=79 alt=image src="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjbEVXoAfULvQg64LQnDPtwJbFJVdT6jYHPRWvYz4xLPermHgkq-67SFz0i7Yp8tbSlbbFNHTn4Ka94T_w8Vo4F7?PARTNER=WRITER" width=602 border=0&gt;&lt;/a&gt; 
&lt;p&gt;I should explain (or remind you if you knew this already) that the foreground and background fill colors are only both used  when the fill pattern is not 1 (Solid).  In fact, the presentation of foreground and background is reversed in the user interface when a fill pattern is not Solid. 
&lt;p&gt;This is the standard fill patterns, starting with no fill, then white (RGB(255,255,255)) solid fill foreground then applying each standard fill pattern with a blue (RGB(31, 71, 125)) pattern color.  Notice how the FillForegnd and FillBkgnd cell values switch above a FillPattern of 1. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjZknA4WyX1GKeR3dCk1Q34_kponx3SDk1nHFY8O-hyjnZ0SlNllFYnyuWiJTkT2U8FvFaSqWXRZoaqP8A03RTv5?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=402 alt=image src="http://blu1.storage.msn.com/y1p-mAN70zrGh2pa7c3iWZnEdwzEHyaeCshOz3iYFX0cRi-2kt79nxFG6H2sVj2XI9Z58MEETB0QBP64xEqwlu8jjg1yjEtgWCU?PARTNER=WRITER" width=600 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Now, the Data Graphic Color By Value uses Solid colors, therefore it is necessary to look at the reverse of the above to get a better idea of how these fill patterns would appear in a shape. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjbGwQpUnosriQLO5FO1NvDRvSMQ6XRMIdRi7qIJPWOTux_UqDNx1LBiKxnBUWE-BFcY1Sc-KntIkYZH4Uog4muu?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=403 alt=image src="http://blu1.storage.msn.com/y1p-mAN70zrGh3jV_BxyaGdlAU9pMzCqghzE9uAQkBPoN117Eok6UQTTRpE1ZItSQtJo1GPeMAYnIz_V2oh7AZGH_e_1ML_MITu?PARTNER=WRITER" width=599 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Now, not all shapes will be rectangular in appearance, so some patterns work better than others. 
&lt;p&gt;So, here are 40 different departments using the default color by value colors... 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjbqf_4asPFvvlJXYhEG0FISJ6BFeF0NIpAmXIUVFMJG0KYQjCl58C0GFD3GbqjzYVCpXSDcajeBDc36HO1chu_O?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=310 alt=image src="http://blu1.storage.msn.com/y1p-mAN70zrGh0iw3IQ45aaCU7dqODTzZ186R-bu53X_5Nj_WZtp5oLcv8EHmy3hG49K_aBID14JU6ap5jJQRJtIYUei02dOcsc?PARTNER=WRITER" width=599 border=0&gt;&lt;/a&gt; 
&lt;p&gt;As you can see, it is a little difficult to distinguish some of the colors because they are exactly the same! 
&lt;p&gt;In the screenshot below, I have applied a VBA function, UpdateCBVFillPatterns, which has additionally cycled through a list of fill pattern numbers (in this case &amp;quot;13;14;15;16;17;18&amp;quot; ).  
&lt;p&gt;You can now visually distinguish different departments! 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjbaJXmQfo3E9D6F2ejPICdIJRDreP_nAq-cIktsxRAc7Gp_oVKTWX9KMhjrtDsxc8K2mdyKFCuxjH1vepR4xaon?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=310 alt=image src="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjaEpZz92fPh8PxO-4sjyFXbH_v7UBckTJSMa5NCwUrHPMpVarEbN0ybK0lwMudINu1WncFYRPGwPJpn9QnV_Hpk?PARTNER=WRITER" width=601 border=0&gt;&lt;/a&gt; 
&lt;p&gt;I have included the whole VBA code below for you to try.  Please note that this currently expects you to select one shape that uses Color By Value before running the it, and it only updates the active page, but it could be extended to update the whole document quite easily. 
&lt;p&gt;In addition, I am looking into extending the legends created by our own DataLegends product (&lt;a href="http://www.bvisual.net/Products/DataLegends.aspx" target="_blank"&gt;http://www.bvisual.net/Products/DataLegends.aspx&lt;/a&gt; ) to also show the fill patterns.  
&lt;p&gt;Public Sub UpdateCBVFillPatterns()&lt;br&gt;Dim shp As Visio.Shape&lt;br&gt;    If Visio.ActiveWindow.Selection.Count = 0 Then&lt;br&gt;        MsgBox &amp;quot;There is no shape selected!&amp;quot;&lt;br&gt;        Exit Sub&lt;br&gt;    Else&lt;br&gt;        Set shp = Visio.ActiveWindow.Selection.PrimaryItem&lt;br&gt;    End If&lt;br&gt;Dim mstDG As Visio.Master&lt;br&gt;    If shp.DataGraphic Is Nothing Then&lt;br&gt;        MsgBox &amp;quot;The selected shape does not have a data graphic!&amp;quot;&lt;br&gt;        Exit Sub&lt;br&gt;    Else&lt;br&gt;        Set mstDG = shp.DataGraphic&lt;br&gt;    End If&lt;br&gt;Dim gi As Visio.GraphicItem&lt;br&gt;    For Each gi In mstDG.GraphicItems&lt;br&gt;        If gi.Type = visTypeColorByValue Then&lt;br&gt;            Exit For&lt;br&gt;        End If&lt;br&gt;    Next gi&lt;br&gt;    If gi.Type &amp;lt;&amp;gt; visTypeColorByValue Then&lt;br&gt;        MsgBox &amp;quot;The selected shape does not have a Color by Value graphic item!&amp;quot;&lt;br&gt;        Exit Sub&lt;br&gt;    End If&lt;br&gt;'Enter the list of standard patterns to use&lt;br&gt;Dim patternList As String&lt;br&gt;    patternList = &amp;quot;13;14;15;16;17;18&amp;quot; 
&lt;p&gt;Dim bkgndColor As String&lt;br&gt;    bkgndColor = &amp;quot;RGB(255,255,255)&amp;quot;&lt;br&gt;Dim mst As Visio.Master&lt;br&gt;Dim shpMst As Visio.Shape 
&lt;p&gt;&lt;br&gt;'The Shape could have a master, so best to update it&lt;br&gt;If Not shp.Master Is Nothing Then&lt;br&gt;    Set mst = shp.Master.Open&lt;br&gt;    addTriggerCell mst.Shapes(1), patternList, bkgndColor&lt;br&gt;    'Could be applied to a sub-shape&lt;br&gt;    For Each shpMst In mst.Shapes(1).Shapes&lt;br&gt;        addTriggerCell shpMst, patternList, bkgndColor&lt;br&gt;    Next&lt;br&gt;    mst.Close&lt;br&gt;End If 
&lt;p&gt;Dim sel As Visio.Selection&lt;br&gt;Dim shpSel As Visio.Shape&lt;br&gt;Dim shpSub As Visio.Shape&lt;br&gt;    'Select all of the shapes in the active page that use this Data Graphic&lt;br&gt;    Set sel = Visio.ActivePage.CreateSelection(visSelTypeByDataGraphic, 0, mstDG)&lt;br&gt;    For Each shpSel In sel&lt;br&gt;        addTriggerCell shpSel, patternList, bkgndColor&lt;br&gt;        'Could be applied to a sub-shape&lt;br&gt;        For Each shpSub In shpSel.Shapes&lt;br&gt;            addTriggerCell shpSub, patternList, bkgndColor&lt;br&gt;        Next&lt;br&gt;    Next&lt;br&gt;End Sub 
&lt;p&gt;Private Sub addTriggerCell(ByVal shp As Visio.Shape, _&lt;br&gt;    ByVal patternList As String, ByVal bkgndColor As String)&lt;br&gt;    'Check that visDGCBVFill cell exists&lt;br&gt;    If shp.CellExists(&amp;quot;User.visDGCBVFill&amp;quot;, Visio.VisExistsFlags.visExistsLocally) = 0 Then&lt;br&gt;        Exit Sub&lt;br&gt;    End If&lt;br&gt;'Get the color formula&lt;br&gt;Dim clrFormula As String&lt;br&gt;    clrFormula = shp.Cells(&amp;quot;User.visDGCBVFill&amp;quot;).FormulaU 
&lt;p&gt;'Collect the matching values in order&lt;br&gt;Dim aryFormula() As String&lt;br&gt;    aryFormula = Split(clrFormula, &amp;quot;STRSAME(&amp;quot;) 
&lt;p&gt;If UBound(aryFormula) &amp;lt; 1 Then&lt;br&gt;    Exit Sub&lt;br&gt;End If 
&lt;p&gt;&lt;br&gt;Dim ipart As Integer&lt;br&gt;Dim aryValues() As String&lt;br&gt;    For ipart = 1 To UBound(aryFormula)&lt;br&gt;        ReDim Preserve aryValues(ipart - 1)&lt;br&gt;        aryValues(ipart - 1) = Split(aryFormula(ipart), &amp;quot;,&amp;quot;)(0)&lt;br&gt;    Next ipart 
&lt;p&gt;'Get the cell reference&lt;br&gt;Dim cellRef As String&lt;br&gt;    cellRef = Split(aryFormula(1), &amp;quot;,&amp;quot;)(1)&lt;br&gt;'Create the index of the value from the lookup list&lt;br&gt;Dim idxPart As String&lt;br&gt;    idxPart = &amp;quot;LOOKUP(&amp;quot; &amp;amp; cellRef &amp;amp; &amp;quot;,&amp;quot;&amp;quot;&amp;quot; &amp;amp; Replace(Join(aryValues, &amp;quot;;&amp;quot;), &amp;quot;&amp;quot;&amp;quot;&amp;quot;, &amp;quot;&amp;quot;) &amp;amp; &amp;quot;&amp;quot;&amp;quot;)&amp;quot;&lt;br&gt;Dim aryPatterns() As String&lt;br&gt;    aryPatterns() = Split(patternList, &amp;quot;;&amp;quot;)&lt;br&gt;'Build the trigger formula&lt;br&gt;Dim tFormula As String&lt;br&gt;    tFormula = &amp;quot;DEPENDSON(User.visDGCBVFill)&amp;quot;&lt;br&gt;    tFormula = tFormula &amp;amp; &amp;quot;+SETF(GetRef(FillPattern),INDEX(MODULUS(&amp;quot;&lt;br&gt;    tFormula = tFormula &amp;amp; idxPart &amp;amp; &amp;quot;,&amp;quot; &amp;amp; CStr(UBound(aryPatterns) + 1)&lt;br&gt;    tFormula = tFormula &amp;amp; &amp;quot;),&amp;quot;&amp;quot;&amp;quot; &amp;amp; patternList &amp;amp; &amp;quot;&amp;quot;&amp;quot;))&amp;quot;&lt;br&gt;    tFormula = tFormula &amp;amp; &amp;quot;+IF(INDEX(MODULUS(&amp;quot;&lt;br&gt;    tFormula = tFormula &amp;amp; idxPart &amp;amp; &amp;quot;,&amp;quot; &amp;amp; CStr(UBound(aryPatterns) + 1)&lt;br&gt;    tFormula = tFormula &amp;amp; &amp;quot;),&amp;quot;&amp;quot;&amp;quot; &amp;amp; patternList &amp;amp; &amp;quot;&amp;quot;&amp;quot;)&amp;quot;&lt;br&gt;    tFormula = tFormula &amp;amp; &amp;quot; &amp;lt; 2,SETF(GetRef(FillBkgnd),&amp;quot; &amp;amp; bkgndColor &amp;amp; &amp;quot;),&amp;quot;&lt;br&gt;    tFormula = tFormula &amp;amp; &amp;quot;SETF(GetRef(FillForegnd),&amp;quot; &amp;amp; bkgndColor &amp;amp; &amp;quot;))&amp;quot;&lt;br&gt;Dim irow As Integer&lt;br&gt;    If shp.CellExistsU(&amp;quot;User.PatternTrigger&amp;quot;, Visio.VisExistsFlags.visExistsAnywhere) = 0 Then&lt;br&gt;        irow = shp.AddNamedRow(Visio.visSectionUser, &amp;quot;PatternTrigger&amp;quot;, 0)&lt;br&gt;    Else&lt;br&gt;        shp.Cells(&amp;quot;User.PatternTrigger&amp;quot;).FormulaU = &amp;quot;=&amp;quot;&lt;br&gt;    End If 
&lt;p&gt;    'Apply the formula&lt;br&gt;    shp.Cells(&amp;quot;User.PatternTrigger&amp;quot;).FormulaU = &amp;quot;=&amp;quot; &amp;amp; tFormula 
&lt;p&gt;End Sub&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=3697690708899476393&amp;page=RSS%3a+Using+Fill+Patterns+with+DataGraphic+Color+By+Value&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=bvisual.spaces.live.com&amp;amp;GT1=bVisual"&gt;</description><comments>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!313.entry#comment</comments><guid isPermaLink="true">http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!313.entry</guid><pubDate>Mon, 17 Mar 2008 12:20:56 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://bVisual.spaces.live.com/blog/cns!3350D61BC93733A9!313/comments/feed.rss</wfw:commentRss><wfw:comment>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!313.entry#comment</wfw:comment><dcterms:modified>2008-06-17T14:49:41Z</dcterms:modified></item><item><title>Visualizing Information the Smart (Diagram) Way</title><link>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!277.entry</link><description>&lt;p&gt;Those of you who are attending the Visio Conference in Redmond this week will know that I am presenting in the developer track.  I am demonstrating some automation examples for building organization charts from SQL Server AdventureWorks database (slightly enhanced) in Visio 2007 Professional, without using the Org Chart Wizard. 
&lt;p&gt;This means that you have far more flexibility with the diagram layout, and it demonstrates Link Data to Shapes, Data Graphics and Pivot Diagrams. 
&lt;p&gt;The example stencil which includes all of the VBA samples used is attached to this post, along with the PowerPoint slideshow, and the SQL Server scripts to enhance the AdventureWorks database. 
&lt;p&gt;&lt;a title="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/MSVisioConference2008_DJP.vss" href="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/MSVisioConference2008_DJP.vss"&gt;http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/MSVisioConference2008_DJP.vss&lt;/a&gt; 
&lt;p&gt;&lt;a title="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/VisioConf2008_DJP.pptx" href="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/VisioConf2008_DJP.pptx"&gt;http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/VisioConf2008_DJP.pptx&lt;/a&gt; 
&lt;p&gt;&lt;a title="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/VisioConf2008DBScripts.zip" href="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/VisioConf2008DBScripts.zip"&gt;http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/VisioConf2008DBScripts.zip&lt;/a&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=3697690708899476393&amp;page=RSS%3a+Visualizing+Information+the+Smart+(Diagram)+Way&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=bvisual.spaces.live.com&amp;amp;GT1=bVisual"&gt;</description><comments>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!277.entry#comment</comments><guid isPermaLink="true">http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!277.entry</guid><pubDate>Wed, 06 Feb 2008 06:29:21 GMT</pubDate><slash:comments>2</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://bVisual.spaces.live.com/blog/cns!3350D61BC93733A9!277/comments/feed.rss</wfw:commentRss><wfw:comment>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!277.entry#comment</wfw:comment><dcterms:modified>2008-06-17T14:46:27Z</dcterms:modified></item><item><title>Creating PolyLines From Existing Shapes in Visio</title><link>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!260.entry</link><description>&lt;p&gt;A couple of posts in the Visio newsgroups got me thinking this weekend.  One was from an Autocad conversant user who would prefer Visio to draw a continuous line between points rather than doing the normal click, hold and drag with line tool because he has tendonitis; and the other wanted to draw a circle centered on a vertex because he is drawing land boundaries. 
&lt;p&gt;Visio has a &lt;strong&gt;PolyLine&lt;/strong&gt; line type, but, as far as I am aware, it can only be created in code - there is no menu or toolbar button to enable you to use it.  It was introduced for converting CAD lines, and is simply a series of X and Y co-ordinates in a single cell, rather than the normal co-ordinate per row. 
&lt;p&gt;Visio has a &lt;strong&gt;Stamp Tool&lt;/strong&gt;, which used to be on a toolbar out-of-the-box, but it seems to have disappeared in Office Visio 2007.  Fortunately, it is simple to put it back by selecting &lt;em&gt;Add or Remove Buttons / Customize&lt;/em&gt; from the down arrow at the end of any of the toolbars.  This will open the &lt;em&gt;Customize&lt;/em&gt; dialog, and then you can navigate to the &lt;em&gt;Drawing Tools&lt;/em&gt; category, and scroll down to &lt;strong&gt;Stamp Tool&lt;/strong&gt;.  You can then click and drag it onto any toolbar, such as the Drawing toolbar in the example below. 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn7w4mcYXT9H0uyEuPFWwu5HtpIvOqH4JQuj3l58cW07oQgM5Q3lUuQEgNhfzSa1Ktk?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=343 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn4WI67cGfA4voQrjkqMklzjIOw5iIgCGBJElemuwObFP1tXuI5k3s_e2ii880X3dfA?PARTNER=WRITER" width=344 border=0&gt;&lt;/a&gt; 
&lt;p&gt;The &lt;strong&gt;Stamp Tool&lt;/strong&gt; enables you to drop a master shape instance with each click of the mouse.  For example, I have selected the &lt;strong&gt;Sector - graphical&lt;/strong&gt; master from the &lt;strong&gt;Visio Extras /&lt;/strong&gt; &lt;strong&gt;Drawing Tool Shapes&lt;/strong&gt; stencil, then I have selected the &lt;strong&gt;Stamp Tool&lt;/strong&gt; and clicked seven times in the page. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1p5ml5du9jvOyeVAfEgo7pckqK9ph9w-zW-1sYd73K-OmlI6Sgfa84sUvWbLf9GP6u76lpH77Sxsr6Zi2eQD4Krw?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=397 alt=image src="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjZD2uL0xpXtYy8_fyl5UgR3MhJuyq5JeuiAqAiktnY8FGOV51RFKKkTa-D6zxL0JQG1IC5myOS15ZHaNHHHebiq?PARTNER=WRITER" width=605 border=0&gt;&lt;/a&gt; 
&lt;p&gt;To stop the &lt;strong&gt;Stamp Tool&lt;/strong&gt;, simply &lt;strong&gt;Pointer Tool&lt;/strong&gt; on the &lt;strong&gt;Standard&lt;/strong&gt; toolbar.  
&lt;p&gt;I have included the &lt;strong&gt;CreatePolyLine&lt;/strong&gt; VBA macro in this post, which has a boolean argument to optionally delete the existing shapes.  To run the macro, simply select the first shape in the sequence that you want to trace a line between.  I have assumed that you would put down a sequence of shapes, then select my macro immediately after re-selecting the first shape in the sequence. Then I selected my macro &lt;strong&gt;DrawPolyLineBetween&lt;/strong&gt; to draw a line between each of the 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjZZG94uB8W_HPzwhTVQrojE753fcNpk5v2Atr8HdBnUbwna_p4apoybtYMG6B5-QxrlS7HNCLTGOoo7I3Nm8T6F?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=358 alt=image src="http://blu1.storage.msn.com/y1p-mAN70zrGh2Ve5PFQxlAg_46ogp6qE6u6j_Q-HwFQEy3nru0UIZNEwJhI6qWRmVj0QXDpdrxgPtE92X6xO8DauV5cr5AEqFB?PARTNER=WRITER" width=489 border=0&gt;&lt;/a&gt; 
&lt;p&gt;The &lt;strong&gt;Sector - graphical&lt;/strong&gt; shapes can be modified to snap to the geometry of the new polyline shape, if desired. 
&lt;p&gt;&lt;a href="http://blu1.storage.msn.com/y1p-mAN70zrGh1Y6MEeDG-J8RcjBmUSFJLqUsbUm2NnDX28pWrQXJlkycYMM2cICaaktUHY4g68lwyYxTkyk95Gs_wMp2t2DH5H?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=277 alt=image src="http://blu1.storage.msn.com/y1p-mAN70zrGh3-SLOIDk9-oEPWus8PAQSNvelUbd8Ur6GoJp4vfnHGpxsTB_1uuOq3Rseswx0BAGj19Ecj-SsOzORUryVTHi5e?PARTNER=WRITER" width=250 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Alternatively, you can run the &lt;strong&gt;DrawReplacementPolyLine&lt;/strong&gt; macro to create a polyline shape that automatically deletes the original shapes. 
&lt;p&gt;&lt;a href="http://blu1.storage.msn.com/y1p-mAN70zrGh2OLPSKa-y8JGblncO0O3Zdj3XapuEVWJC2fMx66foC6kjDKNRLt-Wcln37zScB9N703dHU3tXR0ZFkFfttASNz?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=272 alt=image src="http://blu1.storage.msn.com/y1p-mAN70zrGh0ISLPo2jVy_JSWM3m12tU_vPAMsWtGA9KTEhfhXVuuUuRHSGaMsWTdfCYnyMvB0eKMLjlC6ESYqNqTgZRIzj0n?PARTNER=WRITER" width=248 border=0&gt;&lt;/a&gt; 
&lt;p&gt;The new polyline shape has a single geometry section in the ShapeSheet, which uses the &lt;em&gt;PolyLineTo&lt;/em&gt; row type, as follows: 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjbkT14qrUdCv2ntcQKSNvG5jokOLUjGfzoOz4xaDdCe5miqWg6Ns7cO8vL4F21fcdvexjQhouYaMuTK6UpDIsy-?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=71 alt=image src="http://blu1.storage.msn.com/y1p-mAN70zrGh1ce8sHEO0XiJr3aL-gGTxMNHY4Z_MET-qP33eXaXmVnpJJkdCBiZ4oiuDLd5SmkwCt9IHP8aoG6MnQIxda2gfz?PARTNER=WRITER" width=582 border=0&gt;&lt;/a&gt;  
&lt;p&gt;In the following code, I have tested the vertex shapes to see if they are 1D or not.  If they are 1D, then I have used the &lt;strong&gt;BeginX&lt;/strong&gt; and &lt;strong&gt;BeginY&lt;/strong&gt; co-ordinates as the vertex position, but if they are not 1D, then I have use the &lt;strong&gt;PinX&lt;/strong&gt; and &lt;strong&gt;PinY&lt;/strong&gt; co-ordinates.  I have assumed that you are trying to create a closed shape - that is one where the line returns to where it started from. 
&lt;p&gt;Public Sub DrawPolyLineBetween()&lt;br&gt;    CreatePolyLine False&lt;br&gt;End Sub 
&lt;p&gt;Public Sub DrawReplacementPolyLine()&lt;br&gt;    CreatePolyLine True&lt;br&gt;End Sub 
&lt;p&gt;Private Sub CreatePolyLine(ByVal deleteOriginalShapes As Boolean)&lt;br&gt;'Author: David J Parker, bVisual - Dec 2007&lt;br&gt;'Usage : Draw a poly line between existing shapes&lt;br&gt;'Params: Optionally delete existing shapes&lt;br&gt;    If Visio.ActiveWindow.Selection.Count = 0 Then&lt;br&gt;        'Nothing selected&lt;br&gt;        Exit Sub&lt;br&gt;    End If&lt;br&gt;Dim pag As Visio.Page&lt;br&gt;Dim shp As Visio.Shape 
&lt;p&gt;    Set shp = Visio.ActiveWindow.Selection.PrimaryItem&lt;br&gt;    Set pag = Visio.ActivePage 
&lt;p&gt;    If pag.Shapes.Count = shp.Index Then&lt;br&gt;        'No subsequent shapes to loop thru'&lt;br&gt;        Exit Sub&lt;br&gt;    End If&lt;br&gt;Dim shpIndex As Integer&lt;br&gt;Dim vertexShape As Visio.Shape&lt;br&gt;Dim lineShape As Visio.Shape&lt;br&gt;Dim vertices As Integer&lt;br&gt;Dim xyArray() As Double 
&lt;p&gt;    For shpIndex = shp.Index To pag.Shapes.Count&lt;br&gt;        Set vertexShape = pag.Shapes(shpIndex)&lt;br&gt;        vertices = vertices + 1&lt;br&gt;        setVertices xyArray(), vertexShape, vertices&lt;br&gt;    Next shpIndex 
&lt;p&gt;    'Close the line&lt;br&gt;    Set vertexShape = pag.Shapes(shp.Index)&lt;br&gt;    vertices = vertices + 1&lt;br&gt;    setVertices xyArray(), vertexShape, vertices&lt;br&gt;    Set lineShape = pag.DrawPolyline(xyArray(), 0)&lt;br&gt;    If deleteOriginalShapes = True Then&lt;br&gt;        For shpIndex = pag.Shapes.Count - 1 To shp.Index Step -1&lt;br&gt;            pag.Shapes(shpIndex).Delete&lt;br&gt;        Next shpIndex&lt;br&gt;    End If&lt;br&gt;End Sub 
&lt;p&gt;Private Sub setVertices(ByRef xyArray() As Double, _&lt;br&gt;    ByVal vertexShape As Visio.Shape, ByVal vertices As Integer)&lt;br&gt;    ReDim Preserve xyArray((2 * vertices) - 1)&lt;br&gt;    If vertexShape.OneD = 0 Then&lt;br&gt;        xyArray((2 * vertices) - 2) = vertexShape.CellsSRC( _&lt;br&gt;            Visio.VisSectionIndices.visSectionObject, _&lt;br&gt;            Visio.VisRowIndices.visRowXFormOut, _&lt;br&gt;            Visio.visXFormPinX).ResultIU&lt;br&gt;        xyArray((2 * vertices) - 1) = vertexShape.CellsSRC( _&lt;br&gt;            Visio.VisSectionIndices.visSectionObject, _&lt;br&gt;            Visio.VisRowIndices.visRowXFormOut, _&lt;br&gt;            Visio.visXFormPinY).ResultIU&lt;br&gt;    Else&lt;br&gt;        xyArray((2 * vertices) - 2) = vertexShape.CellsSRC( _&lt;br&gt;            Visio.VisSectionIndices.visSectionObject, _&lt;br&gt;            Visio.VisRowIndices.visRowXForm1D, _&lt;br&gt;            Visio.vis1DBeginX).ResultIU&lt;br&gt;        xyArray((2 * vertices) - 1) = vertexShape.CellsSRC( _&lt;br&gt;            Visio.VisSectionIndices.visSectionObject, _&lt;br&gt;            Visio.VisRowIndices.visRowXForm1D, _&lt;br&gt;            Visio.vis1DBeginY).ResultIU&lt;br&gt;    End If&lt;br&gt;End Sub 
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note to Microsoft Visio team:-&lt;/em&gt;&lt;/strong&gt; 
&lt;p&gt;In preparation for this blog entry, I noticed that the &lt;strong&gt;Stamp Tool&lt;/strong&gt; has a bug, or at least it behaves differently from normal usage. - if the page is scaled then the stamped master instances are scaled, but the same master, when dragged from the stencil, are &lt;em&gt;sometimes&lt;/em&gt; not.  Thus the two operations do not produce a shape of the same size:- 
&lt;p&gt;&lt;a href="http://blu1.storage.msn.com/y1p-mAN70zrGh04_AW1VmmTPnmr0003_VETr4x73DyFqVOOTm6F6g8umEQ8A70azvy-49PDh0UZ7ix2EACEMdRNkyQzqT9wCsaP?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=260 alt=image src="http://blu1.storage.msn.com/y1p-mAN70zrGh0WM1GeQ0ARaaQtJ2aQ8cH4bzAhG36gwn7-pVc9947pD0aXGHSZLH-2eghrji21Wt6SCWcXOCZqyw8dU6h7hwSY?PARTNER=WRITER" width=230 border=0&gt;&lt;/a&gt; 
&lt;p&gt;In my limited testing, this behavior is limited to more complex 1D masters.&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=3697690708899476393&amp;page=RSS%3a+Creating+PolyLines+From+Existing+Shapes+in+Visio&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=bvisual.spaces.live.com&amp;amp;GT1=bVisual"&gt;</description><comments>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!260.entry#comment</comments><guid isPermaLink="true">http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!260.entry</guid><pubDate>Mon, 10 Dec 2007 17:30:46 GMT</pubDate><slash:comments>4</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://bVisual.spaces.live.com/blog/cns!3350D61BC93733A9!260/comments/feed.rss</wfw:commentRss><wfw:comment>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!260.entry#comment</wfw:comment><dcterms:modified>2008-06-17T14:47:40Z</dcterms:modified></item><item><title>Importing Hyperlinks into Visio Shapes</title><link>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!238.entry</link><description>&lt;p&gt;Visio shapes can have multiple hyperlinks, but it can be a chore to add them with the Insert / Hyperlinks ... command.  Fortunately, Visio 2007 Professional has the Data / Link Data to Shapes ... command. 
&lt;p&gt;If you were to have a data source, such as an Excel spreadsheet, that contains hyperlinks (see the example below)... 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjZMB-RAjbnOyUFMzJXBZVC4xRO_VNO8FfOlNmMO1aeRDZlHVWH_1EU3rVR95lDe0U5eWb4XIMWRMmgNPhk5rSmy?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=82 alt=ExcelHyperlinks src="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjYq4GE2g_yZ4tXLmrEG9OUj_Z9QtrNI0DBscK6vbTp43Ivi71KJKPufMxI3nCtcpR_df5Hs3DBJNAlcZh1U3Q6x?PARTNER=WRITER" width=605 border=0&gt;&lt;/a&gt; 
&lt;p&gt;... then you can import these hyperlinks onto shapes, and they will be added, not only as Shape Data, but also as hyperlinks! In the example below, I have enhanced the Data Graphics to display the Shape Data on each shape. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjapqlA2xs0LJ8bwn6b59s9SwfxZIsDAXWsFegvcNJLoLJbvL2QZrYuypsJgoevys8jBr3gel_utHVostD6qyQOF?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=436 alt=HyperlinksInVisio src="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjaFdOara6knJ4buxcmGuw570Zb_rUX8tpzu_hrjThlX3AF4STdwURx_qA5SGO2v3NsqFzmaGj1SSp-qZq765C3E?PARTNER=WRITER" width=604 border=0&gt;&lt;/a&gt;  
&lt;p&gt;When you save the Visio document to a web page as VML, then the multiple hyperlinks are available on each shape! 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjZhmOEJWgFZb2QBSx-WvhJp9Y3LYJ7QOzDyNPope_ORhjkl34276sW08pagb3Gdz7mPd468HnNnL_4FVtoiklpe?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=365 alt=WebPageHyperlinks src="http://blu1.storage.msn.com/y1p-mAN70zrGh3_XarOBXCYSFrspUTgt2hbbh2hqh0Beb8qCgys5JMJHTtJlS0bm-nAVwoHfSKLxJxCN2hI5DAuViRCsjDjrlRA?PARTNER=WRITER" width=599 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Unfortunately, the PDF and XPS exports don't preserver the multiple hyperlinks - just the first one.&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=3697690708899476393&amp;page=RSS%3a+Importing+Hyperlinks+into+Visio+Shapes&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=bvisual.spaces.live.com&amp;amp;GT1=bVisual"&gt;</description><comments>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!238.entry#comment</comments><guid isPermaLink="true">http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!238.entry</guid><pubDate>Thu, 15 Nov 2007 22:07:40 GMT</pubDate><slash:comments>5</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://bVisual.spaces.live.com/blog/cns!3350D61BC93733A9!238/comments/feed.rss</wfw:commentRss><wfw:comment>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!238.entry#comment</wfw:comment><dcterms:modified>2008-06-17T14:47:08Z</dcterms:modified></item><item><title>Finding a Row in a Visio DataRecordset</title><link>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!231.entry</link><description>&lt;p&gt;A recent newsgroup post asked how to find a row in a Visio DataRecordset for a given criteria.  Well, I have used the IT Asset Management sample in Visio 2007 Professional to demonstrate how this can be done with a VBA function. 
&lt;p&gt;Of course, you may wish to improve the user interface because I limited myself to using an InputBox, and I have assumed that there is only one column defining the primary key of the DataRecordset. 
&lt;p&gt;The sub function, FindRow, listed below first checks whether the External Data window is open, and then gets the active DataRecordset.  The code then reads the columns of the DataRecordset and prompts for a selection of the number of the column that you wish to search for a value in. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1p5ml5du9jvOx3PALXQMzx9PULzJgO5mZ1YndnNoatwiPqCeE72j8L_EaGj5NYhA4L4SpSo1Miuub4DYUqPhj-xQ?PARTNER=WRITER"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px" height=472 alt=image src="http://blu1.storage.msn.com/y1p-mAN70zrGh2wxQXOXMbNIme6sARrfFxbXKP7VbLUY3cko9GARw0Y5E0ANc8Cx3uxwYeYumq6g2PMSqJkh8pQsei8WUoTLEvW?PARTNER=WRITER" width=598 border=0&gt;&lt;/a&gt; 
&lt;p&gt;The code will abort if an incorrect number is entered, otherwise you will be asked to enter the text to find in the column.  Note that you can enter a wildcard &amp;quot;*&amp;quot; character. 
&lt;p&gt;&lt;a href="http://blu1.storage.msn.com/y1p-mAN70zrGh14xZxeLKJcfqLdOF62yoYp7XEPLwrMIMIGTin7NyVMBWcT9n6fvLZynTAP2U8u5rHnTG5ZNksSMiq2-Aq9A191?PARTNER=WRITER"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px" height=130 alt=image src="http://blu1.storage.msn.com/y1p-mAN70zrGh00lmronbkzKiQo62E9Ig64XFCGCmilq-FjYkMV9ovKNd1i5bbjUGgvzX1mF8ZochFN6tUzJyns41g2ry89527X?PARTNER=WRITER" width=294 border=0&gt;&lt;/a&gt; 
&lt;p&gt;You will then be prompted to enter the row number of the row that you want to navigate to in the External Data window.  Note that you will not be prompted to select a row if there is only one matching row. 
&lt;p&gt;&lt;a href="http://blu1.storage.msn.com/y1p-mAN70zrGh1dEGHvF2Js-IABMLDD6XOOhzRfJ9S0WP3pJ-26zoQcsb_0HrOMjOl_B7aY1smmPJwslFA-S4NEhpihVbMFFxY8?PARTNER=WRITER"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px" height=127 alt=image src="http://blu1.storage.msn.com/y1p-mAN70zrGh2KtEh_zQu0bZlH6Uys4VTZKdx7_7TsBKyAbrTFnw5ublY9bIuYK3cz7XOmhIrZN3FUAHF19lLBSNLPRKCTXt1E?PARTNER=WRITER" width=294 border=0&gt;&lt;/a&gt; 
&lt;p&gt;When you enter a row number, the code gets the related row ID, and uses this to select the row in the External Data window. 
&lt;p&gt;&lt;a href="http://j8zpeg.blu.livefilestore.com/y1pHeOR1b4etjYGFb1ERSB21PHhxcsSfz0WcU9Uqf3Vt1RPtIrROChboFNVIHWRIGdfCnK-oONuDXUvHCTNy_ZNtyAMA8DOScBl?PARTNER=WRITER"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px" height=143 alt=image src="http://blu1.storage.msn.com/y1p-mAN70zrGh0ysIsIqh005Eja33hcIrlH70UQZN85ibwaKferuuBwo-C4MfyMcHUTr3MvGgNBm1GyxdBhb3x1ZqGUmTt2hoAx?PARTNER=WRITER" width=588 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Here is a listing of the VBA code to find a row by criteria: 
&lt;p&gt;Public Sub FindRow()&lt;br&gt;'David Parker : 11/11/2007&lt;br&gt;'To find a row with a given string in a DataRecordset&lt;br&gt;Dim findString As String&lt;br&gt;Dim colString As String&lt;br&gt;Dim drs As DataRecordset&lt;br&gt;Dim col As DataColumn&lt;br&gt;Dim win As Visio.Window&lt;br&gt;Dim rowids() As Long&lt;br&gt;Dim i As Integer&lt;br&gt;Dim msg As String&lt;br&gt;Dim rowid As Long&lt;br&gt;Dim vData As Variant&lt;br&gt;Dim primKeys() As String&lt;br&gt;Dim primKey As Integer&lt;br&gt;Dim rowString As String 
&lt;p&gt;    'Check the active windows to find the window&lt;br&gt;    For Each win In Visio.ActiveWindow.Windows&lt;br&gt;        'The External Data window has ID = 2044&lt;br&gt;        If win.ID = 2044 Then&lt;br&gt;            Set drs = win.SelectedDataRecordset&lt;br&gt;            Exit For&lt;br&gt;        End If&lt;br&gt;    Next win&lt;br&gt;    If drs Is Nothing Then&lt;br&gt;        MsgBox &amp;quot;You do not have a recordset selected!&amp;quot;&lt;br&gt;        Exit Sub&lt;br&gt;    End If&lt;br&gt;    'Get the primary key (single assumed)&lt;br&gt;    drs.GetPrimaryKey visKeySingle, primKeys&lt;br&gt;    msg = &amp;quot;Enter the number of the column to search:&amp;quot;&lt;br&gt;    i = 1&lt;br&gt;    For Each col In drs.DataColumns&lt;br&gt;        msg = msg &amp;amp; vbCrLf &amp;amp; CStr(i) &amp;amp; vbTab &amp;amp; col.Name&lt;br&gt;        If primKeys(0) = col.Name Then&lt;br&gt;            primKey = i&lt;br&gt;        End If&lt;br&gt;        i = i + 1&lt;br&gt;    Next col&lt;br&gt;    colString = InputBox(msg, , &amp;quot;1&amp;quot;)&lt;br&gt;    If Not IsNumeric(colString) Then&lt;br&gt;        MsgBox &amp;quot;You must enter a number between 1 and &amp;quot; &amp;amp; drs.DataColumns.Count&lt;br&gt;        Exit Sub&lt;br&gt;    ElseIf CInt(colString) &amp;lt; 1 Or CInt(colString) &amp;gt; (drs.DataColumns.Count) Then&lt;br&gt;        MsgBox &amp;quot;You must enter a number between 0 and &amp;quot; &amp;amp; drs.DataColumns.Count&lt;br&gt;        Exit Sub&lt;br&gt;    End If&lt;br&gt;    findString = InputBox(&amp;quot;Enter text to find&amp;quot;)&lt;br&gt;    If Len(findString) = 0 Then&lt;br&gt;        Exit Sub&lt;br&gt;    End If&lt;br&gt;    rowids = drs.GetDataRowIDs(drs.DataColumns.Item(CInt(colString)) &amp;amp; &amp;quot; LIKE '&amp;quot; &amp;amp; findString &amp;amp; &amp;quot;'&amp;quot;) 
&lt;p&gt;    If UBound(rowids) &amp;gt; 0 Then&lt;br&gt;        'Need to ask which row&lt;br&gt;        msg = &amp;quot;Select a row to highlight&amp;quot;&lt;br&gt;        msg = msg &amp;amp; vbCrLf &amp;amp; &amp;quot;Row&amp;quot; &amp;amp; vbTab &amp;amp; drs.DataColumns(primKey).Name &amp;amp; _&lt;br&gt;            vbTab &amp;amp; drs.DataColumns(CInt(colString)).Name&lt;br&gt;        For i = 0 To UBound(rowids)&lt;br&gt;            rowid = rowids(i)&lt;br&gt;            vData = drs.GetRowData(rowid)&lt;br&gt;            msg = msg &amp;amp; vbCrLf &amp;amp; CStr(i + 1) &amp;amp; vbTab &amp;amp; vData(primKey - 1) &amp;amp; _&lt;br&gt;                vbTab &amp;amp; vData(CInt(colString) - 1)&lt;br&gt;        Next i&lt;br&gt;        rowString = InputBox(msg, , &amp;quot;1&amp;quot;)&lt;br&gt;    Else&lt;br&gt;        'Only one row to select&lt;br&gt;        rowid = rowids(0)&lt;br&gt;        vData = drs.GetRowData(rowid)&lt;br&gt;        rowString = &amp;quot;1&amp;quot;&lt;br&gt;    End If&lt;br&gt;    If Not IsNumeric(rowString) Then&lt;br&gt;        MsgBox &amp;quot;You must enter a number between 1 and &amp;quot; &amp;amp; UBound(rowids) + 1&lt;br&gt;        Exit Sub&lt;br&gt;    ElseIf CInt(rowString) &amp;lt; 1 Or CInt(rowString) &amp;gt; (UBound(rowids) + 1) Then&lt;br&gt;        MsgBox &amp;quot;You must enter a number between 1 and &amp;quot; &amp;amp; UBound(rowids) + 1&lt;br&gt;        Exit Sub&lt;br&gt;    End If&lt;br&gt;    'Select the row in the External Data window&lt;br&gt;    win.SelectedDataRowID = rowids(CInt(rowString) - 1)&lt;br&gt;End Sub &lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=3697690708899476393&amp;page=RSS%3a+Finding+a+Row+in+a+Visio+DataRecordset&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=bvisual.spaces.live.com&amp;amp;GT1=bVisual"&gt;</description><comments>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!231.entry#comment</comments><guid isPermaLink="true">http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!231.entry</guid><pubDate>Sun, 11 Nov 2007 22:14:59 GMT</pubDate><slash:comments>1</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://bVisual.spaces.live.com/blog/cns!3350D61BC93733A9!231/comments/feed.rss</wfw:commentRss><wfw:comment>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!231.entry#comment</wfw:comment><dcterms:modified>2008-06-17T14:48:22Z</dcterms:modified></item><item><title>A Working Visio Clock</title><link>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!221.entry</link><description>&lt;p&gt;A recent newsgroup post asked about the ShapeSheet programming of lines in Visio to represent the hands of a clock.  Well, it made me think, so here is my solution of a clock in Visio with just the ShapeSheet, and, for good measure, you can set it to refresh every minute! 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn648DmU0hFBPZQFS4jTwdESsGfk0LdpqKJl0gn5kmsKXrAwgxMytf65YSCbL_IjNpY?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=186 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn4UQTz2bAY2_TdBrXo6hhRBeXciPGLur-7pbO3LyE5EYErhN1jyk_Yn9QxOoCBlyoY?PARTNER=WRITER" width=165 border=0&gt;&lt;/a&gt; The Clock is a group shape which contains three sub shapes, one each for the hour, minute and second hand. 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn50yfik2XlbGXfST5wLM5Syg4WBNwdcEZeBcSicwhwXAc1UYqxnYjXc_3wBCoDO9Hw?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=190 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn4Yl8L_jK-vg4EiLkFs8hqfJjr-Dvg3p3-rucoUOBXEEV3Qo5129rb4GI3LoDZBato?PARTNER=WRITER" width=164 border=0&gt;&lt;/a&gt; The display of the second hand is optional, and this can be changed by using a custom property/shape data row or via the right mouse actions. 
&lt;p&gt;The display of the text is also optional, and the display format of the time is changed according to whether the second hand is displayed. 
&lt;p&gt;I have locked the aspect ratio of the clock (the width is always equal to the height) so that I didn't have to worry about making the hands follow an elliptical path. 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn5C2Zd3p84jbQvkqMvWjs2NSDksE8PUPQO4PgzC57HNwlgWwrwPCWy0L_2dC4utNoM?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=131 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn5gqkFpugR7KkFxV6UGRUiuvw5Z75TRF2oXHS002Ci7-ULBA3j-ujsix0feShmtFeQ?PARTNER=WRITER" width=244 border=0&gt;&lt;/a&gt; The user can enter a time, in the format HH:mm or HH:mm:ss, in the Time property.  Note that this is just a text data type, because if it was DATETIME then the user would be presented with a Calendar picker ... not much good for entering a time.  Alternatively, the user can set Synchronize to TRUE, therefore Visio will update the Time property automatically every minute (see below). 
&lt;p&gt;I then inserted a User-defined cells section and created eight rows. 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn5Cs8P3-MNz3SeNhGUTLTVuZfNITqjbn427CkmRweHaVc2KFVMx6W2HR9_lezSmOrc?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=105 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn44v2X3MKTI8cY_26YQmyd2cykVC5F_yQ8uGnQkpNBhcJ--QU0ffRUQLnZOphczWMw?PARTNER=WRITER" width=608 border=0&gt;&lt;/a&gt; 
&lt;p&gt;The first three rows Hour. Minute and Second, convert the Time property text value into a TIMEVALUE, then extract the HOUR, MINUTE or SECOND part, and finally ensure that the numbers are within the valid range by using the MODULUS function. 
&lt;p&gt;The 5th, 6th and 7th rows take the these part time values and convert them into the swept angle from the horizontal position (3 o'clock).  Note that Visio measures angles anti-clockwise from the horizontal, but a clock hand sweeps clockwise from the vertical (12 o'clock) position. 
&lt;p&gt;The formula in the User.SecondAngle cell is: 
&lt;p&gt;=ANG360(90 deg+(360 deg-360 deg*(User.Second/60))) 
&lt;p&gt;However, the minute hand sweeps, not only for each minute, but increments slightly between each minute according to the number of seconds.  So, the formula for the User.MinuteAngle is: 
&lt;p&gt;=ANG360(90 deg+(360 deg-360 deg*(User.Minute/60))-((360 deg/60)*User.Second/60)) 
&lt;p&gt;Lastly, the hour hand sweeps for each hour, plus an increment for each minute within the hour and each second within the minute.  Thus the formula for the User.HourAngle is: 
&lt;p&gt;=ANG360(90 deg+(360 deg-360 deg*(User.Hour/12))-((360 deg/12)*User.Minute/60)-((360 deg/360)*User.Second/360)) 
&lt;p&gt;The User.Synchronize.Format formula is: 
&lt;p&gt;=FORMAT(NOW(),&amp;quot;HH:mm:ss&amp;quot;) 
&lt;p&gt;This will result in a text value for the time Now(), which evaluates every minute, or whenever the shape is re-evaluated (this could be simply resizing or moving it). 
&lt;p&gt;This text value can then be Prop.Time cell, if the user has elected to synchronize with the current time.  So, the formula in User.Synchronize is: 
&lt;p&gt;=IF(Prop.UseNow,SETF(GetRef(Prop.Time),&amp;quot;=&amp;quot;&amp;quot;&amp;quot;&amp;amp;User.Synchronize.Prompt&amp;amp;&amp;quot;&amp;quot;&amp;quot;&amp;quot;),0) 
&lt;p&gt;Finally,  User.SecondTrigger formula turns off the display of the Secnd hand by default if the user elects to synchronize, because the Now() function only fires every minute: 
&lt;p&gt;=DEPENDSON(Prop.UseNow)+IF(Prop.UseNow,SETF(GetRef(Prop.ShowSecondHand),&amp;quot;FALSE&amp;quot;),0) 
&lt;p&gt;  
&lt;p&gt;I have also allowed for the user to set the relative length of each hand via the Shape Data, where 1 would be the radius of the clock face and, say, 0.5 would be half of the clock face radius.  The user can sub select each of the hands if a different line format is desired, but I have protected the sub-shapes from group formatting. 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn5ty21oPDJg8z7ngq_DoQIEvml4x9WxYkSS02jGiKRR_h9b0c-hXCMgnxNROiProG0?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=77 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn4rVT5ZJTgoemzEGdSzZOxNFos5U0X4o0eJm3WVP_mI3WpZCjC3WI_MesiqzuvBWA8?PARTNER=WRITER" width=610 border=0&gt;&lt;/a&gt; 
&lt;p&gt;The visibility of the SecondHandSize row is controlled by the value in the ShowSecondHand row. 
&lt;p&gt;  
&lt;p&gt;I have used Controls (the yellow diamonds) to mark the centre of the clock, position each hand and the optional text block. 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn4N0qM7vZvgMqM5yNNi_YqcFvA8GrE40oD7wVtbhexuR5jnXmoBRvhZMjD8P8U68mA?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=49 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn5BqkeyyVEDMDLJj8e03U8ayiHJoe4ziDsKi3HA7deDX9fjyI6iFuJPOZknEMvriic?PARTNER=WRITER" width=608 border=0&gt;&lt;/a&gt; 
&lt;p&gt;The position of the end each hand has to be relative to the centre of the clock, and uses the ratio of length entered by the user. 
&lt;p&gt;For example, the formula in the Controls.Hour.X cell is: 
&lt;p&gt;=GUARD(Controls.Centre+(0.5*Prop.HourHandSize*Width)*COS(User.HourAngle)) 
&lt;p&gt;and in Controls.Hour.Y is: 
&lt;p&gt;=GUARD(Controls.Centre+(0.5*Prop.HourHandSize*Height)*SIN(User.HourAngle)) 
&lt;p&gt;Note that the Tip cell for each row shows the relevant part of the Time value. 
&lt;p&gt;The Actions rows simply provide an alternative method of changing the boolean (TRUE/FALSE) SHape Data/Custom Property rows. 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn49a9Jw3wwQbZkFG8lkP9hmY4PC0GG4TyWFQBXFlCx99I28_YuVfwFd_SOxjNAhiPk?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=52 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn6eqpo9B8exLx9X3jte_9ELWsFzYFyeaY3ApRj9CHr5monfk9RnEp0BG32_Dqa1rH4?PARTNER=WRITER" width=610 border=0&gt;&lt;/a&gt; 
&lt;p&gt;The Miscellaneous section of the ShapeSheet provides the opportunity to control the visibility of the text block, and to set the contents of the Screen Tip (Comment). 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn6ZWz5XmjJ3rQRADOzVVAWbnHiSYRPgleSed6YmJwpODreWcutRRSDsGSdZHWtthCw?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=65 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn5bMhbrut6lIMk9pEtmOpFSoeUwuGUKACuHQWmsMDjpUyP1xYJsuf8UWcSSccriwxA?PARTNER=WRITER" width=610 border=0&gt;&lt;/a&gt; 
&lt;p&gt;The formula in the Comment cell is: 
&lt;p&gt;=&amp;quot;Time is &amp;quot;&amp;amp;IF(Prop.ShowSecondHand,FORMAT(TIMEVALUE(Prop.Time),&amp;quot;HH:mm:ss&amp;quot;),FORMAT(TIMEVALUE(Prop.Time),&amp;quot;HH:mm&amp;quot;)) 
&lt;p&gt;Note that I used the same formula in the Text Fields section, after first using Insert / Field .., followed by Shape Data - Time, with the Clock selected.  Remember that you cannot insert Text Fields rows in the 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn7v5g9ZtjmNO5ZcMckSeQWO2-sYjtN6hV9uleLPnG4L3q7N5rft6xvgG_4whce5z5M?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=34 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn5gzR_4onMvPMAbgkYjHi5dTgNfPy73hKmmeRmE3KOg4liqYcX0PqHW-ni0XHZK29c?PARTNER=WRITER" width=607 border=0&gt;&lt;/a&gt; 
&lt;p&gt;I repositioned, and resized the text block of the clock to be just below the clock, but then I modified the Text Transform section in the ShapeSheet by setting the TextPinX and TextPinY formulae to those of the Controls.Text cells. 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn62Im6wEpmqIc-nm55sRY0PcI9L2afzula0DyJcb4wnrVth6bxScl4kWYChP-qghcs?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=77 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn570NhRIWj2LxQ2Beoz0SgFjH88FWwveglq27RIYm7kIEMjPS_XVkiP-bOYn4H7dzM?PARTNER=WRITER" width=612 border=0&gt;&lt;/a&gt; 
&lt;p&gt;So, the final part of the story is how to set the position of the hands! 
&lt;p&gt;Well, as I said, these are three sub-shapes, and each are just a simple straight line that starts at the centre of the clock face, and ends at the relevant Control in the parent shape.  For example, the 1-D Endpoints of the ShapeSheet of the MinuteHand shape was amended as follows.  (Note that the parent/group shape is Sheet.4 in my case - use Format / Special to discover the ID of your shape). 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn5udhCnogNFJ0eczUyCQL3obESDIA-t15FFBtqzTyPt1I3TlRE_GBUe2aH4sUpmtIw?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=74 alt=image src="http://blufiles.storage.msn.com/y1pkvFgsW6TTn4tpmaqppGivKYG9jwSDfQR0-fKX5C1PpDG-eeyUp7PHmdWXti8EoFNLrZEfeaKIFU?PARTNER=WRITER" width=603 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Well, I hope the clock is useful, and I have provided the Visio document at &lt;a title="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/ClockFace.vsd" href="http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/ClockFace.vsd"&gt;http://cid-3350d61bc93733a9.skydrive.live.com/self.aspx/Blogs/ClockFace.vsd&lt;/a&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=3697690708899476393&amp;page=RSS%3a+A+Working+Visio+Clock&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=bvisual.spaces.live.com&amp;amp;GT1=bVisual"&gt;</description><comments>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!221.entry#comment</comments><guid isPermaLink="true">http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!221.entry</guid><pubDate>Mon, 05 Nov 2007 10:54:30 GMT</pubDate><slash:comments>3</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://bVisual.spaces.live.com/blog/cns!3350D61BC93733A9!221/comments/feed.rss</wfw:commentRss><wfw:comment>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!221.entry#comment</wfw:comment><dcterms:modified>2008-06-17T14:48:42Z</dcterms:modified></item><item><title>Displaying Document Fonts</title><link>http://bVisual.spaces.live.com/Blog/cns!3350D61BC93733A9!196.entry</link><description>&lt;p&gt;There have been some posts recently about fonts may not displaying correctly in Visio, the Viewer, or in exports to PDF or XPS.  So, I thought it would be good to be have a bit of code that enables you to see all of the different fonts on a Visio page.  You can then use it to select a font, or to check how they are seen in different formats. 
&lt;p&gt;&lt;a href="http://blufiles.storage.msn.com/y1pkvFgsW6TTn5MPld_m8M9R7GAsj1dHaVGPbA1fEkA82tPC-dcplIHA4NmuT4B_b85O0RzprPh0oY?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=733 alt=image src="http://blu1.storage.msn.com/y1p-mAN70zrGh1aDFTYUgCq3_Xcy8BnDNs5c-yznGycTAnN7uWO_tTug2tWxzMlqttfHxY5z5ksRDSl6XQfhY84Kmh3nQOcdMj9?PARTNER=WRITER" width=598 border=0&gt;&lt;/a&gt; 
&lt;p&gt;The following code will divide the active Visio page into three columns, creating a separate shape for each font name in order.  The font index and name are displayed in the particular font, but the ScreenTip of each shape displays the information, just in case you can't read it in the shape! 
&lt;p&gt;Public Sub DisplayFonts()&lt;br&gt;Dim fnt As Visio.Font&lt;br&gt;Dim shp As Visio.Shape&lt;br&gt;Dim cols As Integer&lt;br&gt;Dim col As Integer&lt;br&gt;Dim maxRows As Integer&lt;br&gt;Dim row As Integer 
&lt;p&gt;Dim x1 As Double&lt;br&gt;Dim y1 As Double&lt;br&gt;Dim x2 As Double&lt;br&gt;Dim y2 As Double&lt;br&gt;Dim width As Double&lt;br&gt;Dim height As Double 
&lt;p&gt;    cols = 3&lt;br&gt;    col = 0&lt;br&gt;    maxRows = CInt(1 + (Visio.ActiveDocument.Fonts.Count / cols))&lt;br&gt;    width = ((Visio.ActivePage.PageSheet.Cells(&amp;quot;PageWidth&amp;quot;).ResultIU - _&lt;br&gt;            Visio.ActivePage.PageSheet.Cells(&amp;quot;PageLeftMargin&amp;quot;).ResultIU - _&lt;br&gt;            Visio.ActivePage.PageSheet.Cells(&amp;quot;PageRightMargin&amp;quot;).ResultIU) / cols)&lt;br&gt;    height = ((Visio.ActivePage.PageSheet.Cells(&amp;quot;PageHeight&amp;quot;).ResultIU - _&lt;br&gt;            Visio.ActivePage.PageSheet.Cells(&amp;quot;PageTopMargin&amp;quot;).ResultIU - _&lt;br&gt;            Visio.ActivePage.PageSheet.Cells(&amp;quot;PageBottomMargin&amp;quot;).ResultIU) / maxRows) 
&lt;p&gt;&lt;br&gt;    For Each fnt In Visio.ActiveDocument.Fonts&lt;br&gt;&lt;br&gt;        If row Mod maxRows = 0 Then&lt;br&gt;            col = col + 1&lt;br&gt;        End If 
&lt;p&gt;        row = row + 1&lt;br&gt;        x1 = Visio.ActivePage.PageSheet.Cells(&