如何在 Visio 组织结构图中显示直接和间接下属人数
一个 Visio 宏,用于在组织结构图中显示下属的直接和间接人数。
我看到很多关于这个问题的帖子,但不幸的是,我找不到一个简单的答案来在 Visio 组织结构图中显示计数。因此,我编写了(也许“修改”更合适)以下宏来实现所需的功能。希望对其他人有所帮助。
RecursiveCount
- 这是一个递归方法,用于计算下属人数,并完成所有工作。CountSubs
- 这是起点。选择组织结构图中最顶层的节点,然后运行此宏。SetCountsToBlank
- 这是一个小助手宏,用于将图表中的所有组织结构图形状重置为空字符串 ("")。MakeBoxesBigger
- 这是另一个小助手宏,它遍历并重新调整形状的大小。当遇到较长的名称等情况时,我使用它并取得了一定的成功。可能还有更好的方法在组织结构图中使用。
Function RecursiveCount(s As Shape) As String
Dim count As Integer
count = 0
dc = s.FromConnects.count - 1
For i = 1 To s.FromConnects.count
If s.Text <> s.FromConnects(i).FromSheet.Connects(2).ToSheet.Text Then
count = count + 1
rc = RecursiveCount(s.FromConnects(i).FromSheet.Connects(2).ToSheet)
count = count + rc
End If
Next
If dc > 0 Then
s.Shapes(4).Text = dc
If (count > 0) And (count <> dc) Then
s.Shapes(4).Text = s.Shapes(4).Text & "(" & count & ")"
End If
End If
RecursiveCount = count
End Function
Sub CountSubs()
' select the top most node then run this macro
Dim s As Shape
Set s = ActiveWindow.Selection(1)
' now recursively update counts
i = RecursiveCount(s)
End Sub
Sub SetCountsToBlank()
Dim s As Shape
For Each s In ActivePage.Shapes
If s.Shapes.count >= 4 Then
s.Shapes(3).Text = ""
s.Shapes(4).Text = ""
End If
Next
End Sub
Sub MakeBoxesBigger()
Dim s As Shape
For Each s In ActivePage.Shapes
If (s.Type = 2) Then
s.CellsSRC(visSectionObject, visRowXFormOut, visXFormWidth).FormulaU = "1.37 in"
s.CellsSRC(visSectionObject, visRowXFormOut, visXFormHeight).FormulaU = "0.6 in"
End If
Next
End Sub