Identify shapes in the 2nd row

Started by ready4data, January 30, 2017, 06:55:01 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ready4data

I'm creating an org chart using VBA. I cobbeled this together from serches. It gets the employee data from a spreadsheet.
Function CreateOrg(strFilename As String, strTopLevel As String)
'Usage CreateOrg("c:\OrgTest.xlsx","Top guy's name")
Dim objVisio As Visio.Application
Set objVisio = CreateObject("Visio.Application")
Set objAddOn = objVisio.Addons.ItemU("OrgCWiz")

strFile = strFilename
strDisplayFields = "Name, Title"
strPropertyFields = "COLOR_CODE"
strFilename = strTopLevel
strTopLevel = Chr(34) & strTopLevel & Chr(34)

strCommand = "/FILENAME=" & strFile _
& " /NAME-FIELD=Name " _
& " /MANAGER-FIELD=ReportsTo " _
& " /DISPLAY-FIELDS=" & strDisplayFields _
& " /PAGES=" & strTopLevel _
& " /SYNC-ACROSS-PAGES " _
& " /HYPERLINK-ACROSS-PAGES " _
& " /SHAPE-FIELD=MASTER_SHAPE "

objAddOn.Run ("/S-INIT")

Dim cmdArray, i
cmdArray = Split(strCommand, "/")
For i = LBound(cmdArray) To UBound(cmdArray)
objAddOn.Run ("/S-ARGSTR /" + cmdArray(i))
Next

objAddOn.Run ("/S-RUN ")
'Turn off grid and page breaks
objVisio.ActiveWindow.ShowPageBreaks = False
objVisio.ActiveWindow.ShowGrid = False
'Resize page
objVisio.ActivePage.ResizeToFitContents
'Export to pdf
objVisio.ActiveDocument.ExportAsFixedFormat visFixedFormatPDF, "C:\" & strFilename & ".pdf", visDocExIntentPrint, visPrintAll
'Save Visio doc
objVisio.ActiveDocument.SaveAs ("C:\" & strFilename & ".vsd")

objVisio.Quit
Set objVisio = Nothing
End Function


I would like to color the shapes only in the second row. How do I identify those shapes and color them after the above code runs?

Thanks,
Scott

wapperdude

Did you solve this?

Are all 2nd rowers from a common manager?   What feature makes them a 2nd row?  Position on the page?  Only one manager above them?


Need some criteria that identifies a shape as belonging to "2nd row".

Wapperdude
Visio 2019 Pro

ready4data

Thanks for the reply. I found a different way to identify them by adding another column.

Scott

wapperdude

Visio 2019 Pro