Displaying the Windows Directory as a Visio Organization Chart

Published on
43,031 Points
8 Endorsements
Last Modified:
Scott Helmers
Visio enthusiast, teacher, and MVP. Co-inventor of TaskMap: process mapping for the rest of us. Avid cyclist. Father of two daughters.
The Question
Several times in recent years, someone has posted a question at EE asking whether they could display the Windows directory structure – folders and subfolders – using Visio. When one person specifically asked about displaying directory info in an organization chart format, experts Scott and oldviking decided to give it a try, with the goal of producing something like this:
Final result for MS Office directoryWhen you think about it, displaying a directory as an org chart is a very logical idea. After all, the Windows directory on a hard drive is a hierarchical structure and the Organization Chart Wizard that comes with Visio was designed to display hierarchical information.

The Two-Part Solution
To get started, Scott wrote an Excel macro that collected names and paths of the subdirectories on a Windows hard drive or network share and wrote the results to the worksheet. The collected data also included the attributes of each directory (Read-only, Hidden, System, Archive and Compressed; see reference 1 below for code that obtains directory attributes).

After some fine tuning by oldviking, the directory listing in Excel for "C:\Program Files\Microsoft Office\" looked like this:
Directory data in ExcelWith an automated way to create the spreadsheet in hand, the authors intended to manually invoke the Visio Org Chart Wizard to read the data and create the directory display.

The Integrated Solution
However, at this point Scott started wondering whether the Org Chart Wizard could be automated. A brief search turned up reference 2 below so he moved the Excel code into a Visio VBA project and added new code to create the Org Chart. To use the resulting code:
Open the Visio file attached to this article
Double-click on the org chart graphic in the center of the page
Org chart graphic in macro document
Navigate to and select a starting directory
Dialog for selecting starting directory
Click OK
NOTE: While the Org Chart Wizard is working you will see a progress indicator like this one:
Progress indicatorA couple of seconds after the progress indicator disappears, Visio will open a new document and display your org chart. The finished result for "C:\Program Files\Microsoft Office\: is shown here:

Final result for MS Office directoryA couple of notes about the appearance and operation of the Windows directory org chart program:
The org chart for your directory structure will be split across multiple pages automatically, if required.
In many cases, subdirectories will be shown on the same page as the parent directory.
If there are many subdirectories under a given directory, the Org Chart Wizard will put them on a new page and will create hyperlinks between pages, in both directions. (If a hyperlink symbol appears beneath the cursor when you hover over any directory rectangle, it is hyperlinked to another page.)
Each rectangle on the directory org chart contains the name of the directory and its attributes.
If a directory has no special attributes, you will see five dashes, e.g.
Directory with no attributes
If a directory has one or more attributes set, the corresponding dash will be replaced by a one of the letters RHASC, corresponding to Read-only, Hidden, System, Archive and Compressed, e.g.,
Directory with attributes
Directories that do not contain subdirectories are shown in a rectangle with a single line border like "Code Samples Library" above.
Directories that contain subdirectories are shown in a rectangle with a double line border like "Favorites" and "Local Settings" above.
If a page contains a large number of directory boxes, the Org Chart Wizard may place some of the boxes off the drawing page but they will still be visible. You can manually resize the drawing page, if desired.
If you choose a directory with many subdirectories, the Org Chart Wizard can take a while to finish, sometimes continuing to work even after the progress indicator disappears. If this happens on your system, the org chart can look a bit strange – see the graphic below – until the wizard does its final cleanup. But don’t despair – another two to ten seconds and you should see the final result.
Near-final resultSystem Requirements
This solution requires both Microsoft Visio and Microsoft Excel to be installed. The Visio macro has been tested with Visio 2003, Visio 2007 and Visio 2010 Release Candidate.

Though it has a few deficiencies, the Visio Org Chart Wizard does a pretty good job of providing a visual representation of Windows directories. Please provide feedback below to let us know whether you like this idea and whether you have suggestions for further refinements.

The EE Article system doesn’t allow for more than one author to get credit for an article. Despite the fact that this article was published under my name, oldviking was a vital part of the concept, code creation, testing, and article writing.

1) VBA code for obtaining directory attribute settings

2) Visio Organization Chart Wizard parameters (Scroll down to “Create a chart from data using the command line or Run method”)

3) VBA code to present the user with a directory browse dialog (See "Using The Windows API Functions")

Ask questions about what you read
If you have a question about something within an article, you can receive help directly from the article author. Experts Exchange article authors are available to answer questions and further the discussion.
Get 7 days free