Org Charts Auto-arrange in VBA


    Sponsored Links


  • 1. Update shape instances when master shape is changed
    I've got a Visio drawing with about 300 instances of a master shape. When I change some of the properties of the master shape it updates all the instances as expected, after it prompts me for whether I want to update all the instances of the master shape. However, I want to make a change to the master shape with some VBA code and get all the instances to update automatically. I have written some code that seems to do this, but it doesn't always update all the instances. Could someone paste a snippet of code that would do this to check that I am on the correct lines, and furthermore, is there a way in VBA to tell it to update all the instances after a change has been made to the master shape (as the prompt would usually do, if the changes were made manually to the master). Many thanks. PugWash
  • 2. Delete Shape Problem
    Can anyone tell me what I'm doing wrong? I got a procedure that drops a red dot ("TestDot") onto the page to the right of each shape that fits a particular criteria. I've then written another procedure (see below) to remove the same dots, based on the masters name (again "TestDot"). The weird thing is that when I run the procedure it only removes some of the dots. I end up have to run the procedure several times to get rid of all of them. Any clues on why it doesn't remove the lot in one go? Thanks John Sub RemoveTestDots() 'Removes all shapes in document named "TestDot" Dim pag As Visio.Page Dim shp As Visio.Shape For Each pag In ActiveDocument.Pages For Each shp In pag.Shapes If shp.Master.Name = "TestDot" Then shp.Delete End If Next shp Next pag End Sub
  • 3. VBA array woes
    Hi everyone, I have a problem passing a class module instance to another class. I have a class module as such: Option Explicit Private Items() As AquaInput Private NumItems As Integer ' Add an item to the end of the array. Public Sub Add(ByVal new_value As AquaInput) ' Add the new item. NumItems = NumItems + 1 Items(NumItems) = new_value End Sub However, whenever I call this Add method from outside. it throws an error that the Object does not support this property or method. However, it is right there. The funny thing is that if I replace AquaInput with built in type like String, it works fine! What am I doing wrong here? It is killing me! Thanks, xargon
  • 4. US Units to Metric in VBE
    Hi there, Can anyone tell me how the Metric/US Units are set in the VBE? Does it refer to each document or is it a global setting? I have, what as far as I can tell is, a metric drawing (page setup uses millimetres), but when I write code in the VBE I end up having to use inches rather than millimetres. This is kind of confusing particularly when I try and drop a shape relative to another. It took some time to work out that the shape was dropped not 10mm to the right of the shape but 10 inches (and off the page!). Thanks John

Org Charts Auto-arrange in VBA

Postby peter.allan » Thu, 28 Sep 2006 18:05:24 GMT

Hello, I'm trying to automate the creation of org-charts using Visio
VBA. I can create the org charts and do a certain amount of
manipulation, however I am struggling to "re-arrange" the shapes on the
page once the chart has been created.

The Org Chart Wizard tends to put subordinates in 2 columns below a
Manager, even where there are 30 or 40 subordinates and the shapes run
off the bottom of the pages. Manually I can improve this by selecting
the Manager, going to Shape -> Actions -> Arrange subordinates on the
menu, and clicking on the relevant button to re-arrange the shapes into
4 columns.

So is there any way I can run this 'auto-arrange' option in VBA ? I
cannot find anything in the Language References on the Microsoft site.

Even better would be some examples of how I can 'move' shapes around
the page more generally so I can move into (for example) 6 columns.

I have also seen reference on here to changing the orgch_u.vst file,
however I don't have one on my pc (I'm using Visio 2000), and I don't
know if it would help in this case anyway.

Any help is greatly appreciated,

RE: Org Charts Auto-arrange in VBA

Postby SnVuZVRoZVNlY29uZA » Thu, 28 Sep 2006 20:50:01 GMT

Sometimes you can get the name of command and parameter
by analysing the menu with vba, though it is not always true.


Re: Org Charts Auto-arrange in VBA

Postby Chris Roth [MVP] » Wed, 04 Oct 2006 20:16:55 GMT

Hi Peter,

I found one of my posts from a few weeks ago related to this topic, and have 
pasted it below. Have a look!

Hope this helps,

Chris Roth
Visio MVP

More Visio shapes, articles, development info and pure diagramming fun at:

Org Chart Commands
Two ideas:

One, you can analyze the Orgchart menu via Visio's UI object to see what the
commands are. Since I don't do this sooo often, I always forget and find it
a bit of a pain...just laziness really.

Two, select an orgchart shape and choose Window > Show ShapeSheet. In the
Actions section, you'll see a bunch of formulas with RUNADDONWARGS. The
add-on is called OrgC11, and you can see a whole slew of parameters that can
be fed to it.

Looking at this, I took a lucky guess and figured "/cmd=LayoutPage" would do
what you needed. Sure enough it works. So you can test in VBA using this
line of code:

Call Visio.Application.Addons.ItemU("OrgC11").Run("/cmd=LayoutPage")

Re: Org Charts Auto-arrange in VBA

Postby peter.allan » Sat, 14 Oct 2006 19:01:08 GMT

Hi Chris,

Thanks for your reply. Regarding the info in your post - when I look at
the ShapeSheet for the employees in my Org Chart the RUNADDONWARGS
seems to be different from yours - there is no add-on called "orgc11",
and no /cmd=Layoutpage option. The only add-on is "orgc".

Do I need to get a new version of Visio (I'm currently using Visio Pro
2002 SR-1) ?

Or is this "orgc11" add-on downloadable, or installable, somehow ?

Thanks very much for any help,

Re: Org Charts Auto-arrange in VBA

Postby John Marshall, MVP » Sun, 15 Oct 2006 04:45:27 GMT

isio 2003's version number is 11, so orgc11 would be for Visio 2003.

John... Visio MVP

Need stencils or ideas?
Need VBA examples?
Visio Wishlist

< XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...

Similar Threads: org chart pictures/hyperlinks from database?

I'm creating an org chart in Visio 2003 that is linked to a database.
I can get the employee data to update in the chart but I would like to
get the inserted pictures and hyperlinks to update based on a path/etc.
contained in database fields.  I've been digging through the Visio
developer help but haven't come up with much so far.  Any help would be


2.Org Chart or Flow Chart Control


Can someone recommend a Org Chart or a Flow Chart Control which I could use 
with vbs?

I would only use the control to display a chart. Functions for modifications 
like an Editor is not a need.


3.Insert Picture in Org. Chart - VBA

How can i insert any picture to any shape in org. chart 
with VBA? 
Could i link picture from Access database?

4.Org Chart Data Import using VBA?

I would be very interested in that code, as that is what I am trying to

Dan Sears wrote:
> I wrote some VBA code in MS Access to create an org chart with VISIO
> using the import feature.
> I use tables in the Access app to supply the data. I open Visio from
> VBA, drop the top manager, then drop the rest of the employees in
> proper positions based on the "ReportsTo" field. If you're interested
> could e-mail you a copy of the mbd.
>     Dan Sears
> "Randal Greene" < XXXX@XXXXX.COM > wrote in message
> news:OnnftUsqBHA.1596@tkmsftngp07...
> > I'd like to automate creating an org chart using data we have in
> > Access/SQL HR app.  Visio has a simple feature for
importing/exporting org
> > data via csv, however I can't seem to access the org data
> > feature using VBA.  Is this possible?  If not, I am new to Visio
VBA, so
> > what is the basic approach to creating the org chart object by
> using
> > code - do you use the Shapes collection?
> >
> > Thanks in advance...
> >
> > org chart pictures/hyperlinks from database?

I'm creating an org chart in Visio 2003 that is linked to a database.
I can get the employee data to update in the chart but I would like to
get the inserted pictures and hyperlinks to update based on a path/etc.
contained in database fields.  I've been digging through the Visio
developer help but haven't come up with much so far.  Any help would be


6. Auto arrange child shapes in parent shape

7. Re-Layout and auto organization does not work in org chart

8. Move org chart without auto-rerouting

Return to VISIO


Who is online

Users browsing this forum: No registered users and 86 guest