News:

BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

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

Browser ID: smf (is_webkit)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 156 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1066KB.
Tokens: post-login.
Cache hits: 13: 0.00210s for 26,764 bytes (show)
Cache misses: 2: (show)
Queries used: 16.

[Show Queries]