Enhancing the Orgchart with different reporting lines

Over the summer I was asked if it was possible to have some of the reporting lines a different pattern. An interesting idea, but how do you mantain the feature when the Orgchart is imported and exported?

For this feature to work the information had to be stored with the person at the bottom of the reporting relationship. The Custom Properties (Soon to be Shape Data) of each person was preserved over imports and exports and was the ideal location. So once the data was imported into Visio VBA code was run to check each 2d shape for a "Reporting Type" Custom Property and change the line pattern of their reporting line to match.

Sub ChangeReportingLines()

' Display connections on the page

Dim conObj         As Visio.Connect
Dim i              As Integer
Dim ReportingType  As String
Dim vsoPage        As Visio.Page
Dim VsoShp         As Visio.Shape

For Each vsoPage In ActiveDocument.Pages
    For Each VsoShp In vsoPage.Shapes
        If Not VsoShp.OneD Then
                           
            nrows = VsoShp.RowCount(Visio.visSectionProp)
   
            For i = 0 To nrows – 1
                If VsoShp.CellsSRC(Visio.visSectionProp, i, visCustPropsLabel).ResultStr(Visio.visNone) = "ReportingType" Then
                    ReportingType = VsoShp.CellsSRC(Visio.visSectionProp, i, visCustPropsValue).ResultStr(Visio.visNone)
                             
                    For Each conObj In VsoShp.FromConnects
                        If conObj.FromPart = visEnd Then
                        Debug.Print "change to –> "; ReportingType
                        Select Case ReportingType
                        Case "Dotted"
                            conObj.FromSheet.CellsSRC(visSectionObject, visRowLine, visLinePattern).FormulaU = "3"
                        Case "Dashed"
                            conObj.FromSheet.CellsSRC(visSectionObject, visRowLine, visLinePattern).FormulaU = "2"
                        Case Else
                            Debug.Print ReportingType
                        End Select
                    End If
                    Next conObj
                              
                End If
            Next i
        End If
    Next VsoShp

Next vsoPage

End Sub

This can be taken further by trapping any changes to the line pattern through the UI and updating the Custom Property to match.

John… Visio MVP

Visio’s other file format – Report Definition files *.VRD

It has been a long standing fact that though there were several Visio file types; stencils, drawing, templates and workspaces, there was a only one Visio file format. Several versions ago, a new file format crept into the Visio file format family. Visio added a reporting facility that used a seperate file to store information about how to create the report.


About the same time, Visio gave the Visio user the oppurtunity to save Visio drawings in XML format. So, the information in the Visio Report Definition (VRD) files is also stored in XML format. For Visio 2003, the third version of the VRD, schemas were created.  (schemas-microsoft-com:office:visio:reportdefinition).


The VRD file is divided into several sections. The first section sets basic information for the report, the title, the description.


The second section, a collection of <VisioRptDefField>s, describes the fields to be used, the column headers and the order.


The third section, a collection of <VisioRptDefFilter>s, describes the filters that would apply to select the information for the report.


The fourth section, <VisioRptDefGroup>, describes how the records are grouped.


The fifth section, a collection of <VisioRptDefSort>s, describe how the information is sorted.


For Visio 2007, there are no new or deleted reports and the only changes are very, very minor corrections to the reports’ description.


So what is the point of knowing this? I have yet to see a request in the Visio newsgroups for automating report creation, but creating or modifying XML will be far easier than trying to control the wizard by Sendkey.


John… Visio MVP