Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visio Automation Org Chart

Status
Not open for further replies.

NewUserMo

Technical User
Mar 15, 2015
23
US
I can make an org chart manually (using the data from excel) through the "Org Chart Wizard" and it works fine. Now, I want to do the same using VBA. I have written the following code but it is not working as expected.

Private Sub CommandButton1_Click()

Dim TxtFileName As String
Dim NameField As String
Dim ManagerField As String
Dim UniqueField As String
Dim DisplayFields As String

TxtFileName = "C:\Users\akash.jain\Desktop\Demo\Employee_data.xlsx"
NameField = "Employee Name"
ManagerField = "Reports To"
UniqueField = "Employee Id"
DisplayFields = "Product"
ShapeFields = "Job Grade"

'ORG CHART WIZARD COMMANDS
strcommand = "/FILENAME=" & TxtFileName _
& " /NAME-FIELD= " & NameField _
& " /MANAGER-FIELD= " & ManagerField _
& " /UNIQUEID-FIELD= " & UniqueField _
& " /SHAPE-FIELD " & ShapeFields _
& " /DISPLAY-FIELDS= " & DisplayFields _
& " /SYNCHRONIZE-ACROSS-PAGES " _
& " /CUSTOM-PROPERTY-FIELDS= " & CustomFields

'START THE ORG CHART WIZARD
Set appvisio = Visio.Application
Set visaddon = appvisio.Addons.Item("OrgCWiz")
visaddon.Run ("/S-INIT")
iMaxArgstringLength = 100
strCommandLeft = strcommand
While (Len(strCommandLeft) > 0)
strCommandPart = Left(strCommandLeft, iMaxArgstringLength)
strCommandLeft = Mid(strCommandLeft, Len(strCommandPart) + 1)
visaddon.Run ("/S-ARGSTR " + strCommandPart)
Wend
visaddon.Run ("/S-RUN ")
End Sub


Following are the problems with this code:
1) It places each node of org chart on a different page :( I want all the nodes to be connected and displayed on the same page i.e page 1
2) I am not able to pass multiple column names in "DisplayFields" and "ShapeFields". How can this be accomplished.

Please help me. I need to get this done urgently. Any help would be greatly appreciated.

Thanks in advance!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top