Hack 47 Use an Outline to Build an Org Chart![]() ![]() excels at managing hierarchical information. This hack shows you how to use an outline to create an organizational chart on the fly.Maintaining a company's organizational charts can be a time-consuming task. Word does include a Diagram feature that makes it easy to create an organizational chart (select Insert challenge, particularly after any substantial reorganization.Unfortunately, the macro recorder ignores diagrams, which removes a valuable tool for deciphering unfamiliar Word objects. But you can still automate diagramsyou just need to decipher the Diagram object on your own. The code in this hack should give you a good starting point.Rather than manipulating an existing diagram, you can store the organizational information in an outline and create the diagram from scratch after any changes. With your organizational information stored in an outline, like the one shown in Figure 5-6, you can quickly add, remove, or rearrange entries. Figure 5-6. Edit your organization information in Outline view![]() diagram like the one shown in Figure 5-7. Figure 5-7. An organizational chart created from an outline![]() make a new one. 5.4.1 The CodePlace this macro in the template of your choice [Hack #50] and either run it from the Tools dialog or put a button for it on a menu or toolbar [Hack #1].The text for the top-level entry (or root node) is culled from the CompanyName property in the outline document. To enter a company name, select File Summary tab. If you don't fill in the property, Word inserts some dummy text.Though your chart could go 10 levels deep (9 for each of Word's outline levels, plus one more for the body-text level), this code goes only 4 levels deep. Adding more levels would require substantially more code, most of which would be nearly identical to that for the first four levels. You'll need to add your own additional code to handle an outline more than four levels deep. Sub MakeOrgChartFromOutline( )Rather than attempting to position elements in the diagram, the macro just relies on Word's default automatic behavior to align and position the entries. |