Creating/placing shapes or graphics relative to Visio org chart sh

K

ker_01

Visio 2007 on XP (Office 2003 also installed). I'm great with Excel VBA, but
don't know the visio object model.

Does anyone have any code snippets that would help me cycle through all the
org chart shapes (based on the first text item in the boxes [names]), and
when a match is found, insert a shape/graph/graphic next to that shape?

I have two performance metrics, and I need to add them visually to the
larger org chart. I can create the graphs in Excel, but have no idea how to
automate getting them onto the visio diagram in the right places. There are
about 50 target names per visio diagram, and 5 diagrams total (each in a
different visio file).

Any pointers or suggestions would be greatly appreciated.

Thank you,
Keith
 
K

ker_01

Thank you for the links! I've been poking around, and also printed a copy of
the Visio object model map.

My first step is to find out how many shapes are on the page, so I can loop
them and check the first line of their text property. However, when I use the
code below, the result is more than 500, even though I only have about 250
shapes visible on the page. This is an org chart with some collapsed nodes; I
suspect it is counting the non-visible boxes as well as the visible ones. I
checked intellesense to try to find some property like shapes.visible= false
but haven't found anything that makes sense. Can anyone suggest the correct
syntax to differentiate between "visible" orgchart boxes, and "collapsed"
boxes?

For example:
Director A has 2 direct reports
Direct report AA has 12 direct reports, all showing
Direct report AB has 8 direct reports, none showing

I'd expect the returned value to be 15 (1 director + 2 managers + 12 direct
reports)

Thanks!
Keith

Code:
Sub ShapesCount()
'Return value
Dim iCount As Integer
'Shapes collection
Dim shpsObj As Visio.Shapes
'Shape object
Dim shpObj As Visio.Shape

iCount = 0
'Assumes root.Shapes is a group or a page
Set shpsObj = Application.ActivePage.Shapes ' root.Shapes
For Each shpObj In shpsObj
If shpObj.Type = visTypeGroup Then
' don't count groups?
' iCount = iCount + ShapesCount(shpObj)
Else
' if shpObj= visible then... syntax?
iCount = iCount + 1
End If
Next

MsgBox iCount
End Sub


philippe c said:
What you have to know is that, for the Visio documentation you have to go
back in time, to year two of this century.
http://msdn.microsoft.com/en-us/library/aa201761(office.10).aspx
http://msdn.microsoft.com/en-us/library/aa201769(office.10).aspx#996

ker_01 said:
Visio 2007 on XP (Office 2003 also installed). I'm great with Excel VBA, but
don't know the visio object model.

Does anyone have any code snippets that would help me cycle through all the
org chart shapes (based on the first text item in the boxes [names]), and
when a match is found, insert a shape/graph/graphic next to that shape?

I have two performance metrics, and I need to add them visually to the
larger org chart. I can create the graphs in Excel, but have no idea how to
automate getting them onto the visio diagram in the right places. There are
about 50 target names per visio diagram, and 5 diagrams total (each in a
different visio file).

Any pointers or suggestions would be greatly appreciated.

Thank you,
Keith
 
P

philippe c

I am not in the mood for programming. I wait for the next Visio version.
Maybe this link could help :
http://visguy.com/vgforum/index.php?topic=832.msg3890;topicseen#msg3890

Thank you for the links! I've been poking around, and also printed a copy of
the Visio object model map.

My first step is to find out how many shapes are on the page, so I can loop
them and check the first line of their text property. However, when I use the
code below, the result is more than 500, even though I only have about 250
shapes visible on the page. This is an org chart with some collapsed nodes; I
suspect it is counting the non-visible boxes as well as the visible ones. I
checked intellesense to try to find some property like shapes.visible= false
but haven't found anything that makes sense. Can anyone suggest the correct
syntax to differentiate between "visible" orgchart boxes, and "collapsed"
boxes?

For example:
Director A has 2 direct reports
Direct report AA has 12 direct reports, all showing
Direct report AB has 8 direct reports, none showing

I'd expect the returned value to be 15 (1 director + 2 managers + 12 direct
reports)

Thanks!
Keith

Code:
Sub ShapesCount()
'Return value
Dim iCount As Integer
'Shapes collection
Dim shpsObj As Visio.Shapes
'Shape object
Dim shpObj As Visio.Shape

iCount = 0
'Assumes root.Shapes is a group or a page
Set shpsObj = Application.ActivePage.Shapes ' root.Shapes
For Each shpObj In shpsObj
If shpObj.Type = visTypeGroup Then
' don't count groups?
' iCount = iCount + ShapesCount(shpObj)
Else
' if shpObj= visible then... syntax?
iCount = iCount + 1
End If
Next

MsgBox iCount
End Sub


philippe c said:
What you have to know is that, for the Visio documentation you have to go
back in time, to year two of this century.
http://msdn.microsoft.com/en-us/library/aa201761(office.10).aspx
http://msdn.microsoft.com/en-us/library/aa201769(office.10).aspx#996

ker_01 said:
Visio 2007 on XP (Office 2003 also installed). I'm great with Excel VBA, but
don't know the visio object model.

Does anyone have any code snippets that would help me cycle through all the
org chart shapes (based on the first text item in the boxes [names]), and
when a match is found, insert a shape/graph/graphic next to that shape?

I have two performance metrics, and I need to add them visually to the
larger org chart. I can create the graphs in Excel, but have no idea how to
automate getting them onto the visio diagram in the right places. There are
about 50 target names per visio diagram, and 5 diagrams total (each in a
different visio file).

Any pointers or suggestions would be greatly appreciated.

Thank you,
Keith
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top