<

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Displaying the Windows Directory as a Visio Organization Chart

Published on
40,015 Points
27,815 Views
7 Endorsements
Last Modified:
Awarded
Community Pick
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.

Summary
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.

Acknowledgments
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.

References
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")

Windows-Directory-as-Org-Chart.vsd
7
Comment
  • 2
  • 2
5 Comments

Expert Comment

by:Lupo09
Scott,

is there a way to tell the wizard where to begin a new page?

As I understand the wizard, it will put the next child objects on another page if there is not enough space on the current one.

I would like to add the information in the Excel-File where I want to split the Orga Chart.

In my case, I want to view sub-departments on new pages although there might be space on the parent department page.

Is there a way to do that?

Thanks,

Kai
0
LVL 31

Author Comment

by:Scott Helmers
Take a look at reference 2 at the bottom of the article; if you scroll down to the list of command line parameters, you'll find this one:
/PAGES=<top employee> <num levels> PAGENAME=<pagename>, <top employee> <num levels> PAGENAME=<pagename>...
I haven't used it but it sounds like what you're looking for.

Scott
0

Expert Comment

by:Lupo09
Thank you, that's the way it works!

At that occasion I have alook at all the other parameters, maybe I can find more interesting stuff there...

Thanks!

Kai
0

Expert Comment

by:Aleksandar Jerinkic
Hi Scott,

Thanks to you and oldviking for writing this macro and ending my search for a good way to visualise the directory trees I need. A question: have you tested the macro for Visio 2013? Every time I try to do a big piece of work I need (over 2000 subdirectories), my visio freezes at some point and becomes unresponsive.
0
LVL 31

Author Comment

by:Scott Helmers
I'm glad you found the code to be useful.

I don't recall but I don't believe that I have run the code with Visio 2013. My guess, however, is that it's the number of directories rather than version of Visio that's the issue in your case. We did not make any attempt to optimize the code for very large file/directory counts. You might be running into the boundaries of either what our code can handle or what the org chart wizard can handle. Also, I don't know how long you've waited before determining that Visio was frozen, but you might start the code when you're leaving your machine for the night to let it run overnight. Just a thought...
0

Featured Post

Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Join & Write a Comment

Wrapper-1-Query. Use an Excel function to calculate a column for an Access query. Part 1. Shows a query in Access that has a calculated column with the results of an Excel worksheet function. See how to call a wrapper function from a query, and …
See the Basics of Office 365's Note Taking app, OneNote

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month