Org Charts Auto-arrange in VBA


    Sponsored Links


  • 1. Open a visio file (.VSD) in read-only format
    I am working on a C# app using Visio designer activex control. I am not able to use OpenEx method to open a file with extension .vsd. Only files with extension .vss can be opened using OpenEx method. My requirement is to open a .vsd file in read only format so that user will not be able to make any changes to the visio file. That is, User cannot delete or move a shape from the .vsd file nor can he add a new shape to the file. Help me out with a solution
  • 2. Open visio file in read-only format in Visio ActiveX control.
    Hi, I am using ActiveX Visio control in my C# winforms Application. I want to open a visio file in Read-Only format so that the user cannot modify the file. How can we do this? Any C# code samples please.... Thanks
  • 3. Getting the name of the connection port on the shape - C#
    I am working on Visio ActiveX control in my C# application. I have created a stencil where each shape has two types of connection ports - Input ports and Output ports. When i connect two shapes using a connector, I have to get the names of the connection ports from the shapes that are connected. This is for validation. I have handled the ConnectionsAdded(Microsoft.Office.Interop.Visio.Connects Connects) event of the current page in the visio control and I am using "Connects.ToSheet property" to get the name of the shape. However i am unable to fetch the name of the connection port on the shape. Please help me out on how to get the connection port names using C# from the shape when connection is established.
  • 4. creating html from shape text
    Hi All, I am using the writeline function to write some HTML to a file. The text comes from a number of shapes on the page. This all works fine as long as the text in the shapes does not contain any special characters. Some characters in the text make the writeline function generate an error (Run-time error '5', Invalid procedure call or argument). I am now looking for a way to determine which characters are causing this 'bad argument' error. Does anyone know of a list of illegal characters, and how to eliminate them, or convert them to legal characters? I have for instance determined that a 'soft return' (shift enter when entering text) gives a problem. However, I cannot find this character when exporting the text. When I do a print.debug of the text, the character shows up as a '?'. But, when I use the Asc() funtion to determine the character, it gives me the value 63. Which is in fact the ascii value of the '?'. A normal '?' does not generate the same error. In the end, I want to convert all special characters (quotes, <, >, etc) to their HTML counterparts. If anyone knows of a function that can do that, I'd be very interested. Hope this makes some sense, and someone has an idea! Jacco Oh, PS: I am using Visio 2003.
  • 5. "If" "Then" conditions
    I want to add an "IF" "Then" condition to a system generated macro (Visio 2003) that is set to activate via a double click on an object. Currently when I double click on object A the following change happens: object A = 1 (white), object B = 2 (red), lines A & B = 4 (blue). How can I add this condition: If object C = 3 (green) then change line C = 4 (blue). Thanks in advance Dave

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. Move org chart without auto-rerouting

8. Auto change position type using custom properties in Org chart

Return to VISIO


Who is online

Users browsing this forum: No registered users and 63 guest