Automate Org Chart w/ Multiple Managers

Started by qwerty1234, November 19, 2010, 01:38:17 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

qwerty1234

Hi Everyone,

I am fairly new to Visio and am using Visio 2003. I am trying to automate the construction of an org chart with multiple managers, while pulling the data from either a spreadsheet or more preferably linked directly to an Access query (maybe using properties to draw in dotted line reports, switching it to solid line).

It seems like there are pieces of Visio that can accomplish each of these actions quickly, but I am having a little trouble mashing it all together. One problem linking a shape to Access is adding/deleting new people from the chart. Additionally, I need help with some of the basic forms of manipulation like how to iterate through all org chart boxes (not lines). I am used to figuring out what is going on with VBA using the macro recorder, but Visio is less forgiving than Excel. Any help at all, even a point in the right direction to a beginner's reference guide/code samples would be helpful.

Thanks.

Jumpy

Don't forget to inform yourself about the ShapeSheet, too. You can look at the Website to this forum www.visguy.com for many many examples in ShapeSheet manipulation and VBA code. But it's not directly a beginners reference or tutorial...

Don't know, if there even realy is one online, know only about books which are mentioned in some threads in this forum.

Problem you have in VBA is Visio's ObjectModel that is imho not so intuitive like Excel.
A short VBA-macro to iterate through shapes.

Sub Test()
Dim doc as Document, Dim pg as Visio.Page, shp as Visio.Shape

For Each doc in Application.Documents   'documents in Visio = workbooks in excel
  For Each pg in doc.Pages                   'pages = (work)sheets
    For Each shp in pg.Shapes                'shapes = shapes/charts/ranges

    'Now do sth. with the Shape:
    shp.Text = "blablabla"
    shp.Cells("Width").Result("mm") = 20         'Cells are Cells in the ShapeSheet
                                                             'each representing a property of the shape
    shp.Cells("Height").Formula = "=2*Width"   'You can place formulas in the cells like in excel

    if shp.OneD = true then MsgBox "Shape 1D"      'Shape OneD normaly means a line or connector
    else MsgBox "Shape 2D"

    Next
  Next
Next
End Sub