I want to put the person's name into the Position Belt shape, but I can't figure out how to make the person's name appear.
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim visApp As New Visio.Application With {
.Visible = True
}
Dim vdocOrgChart As Visio.Document = visApp.Documents.Add("Organization Chart.vst")
Dim vdocShapes As Visio.Document = visApp.Documents("ORGBLT_M.vssx")
Dim vmstPositionBelt As Visio.Master = vdocShapes.Masters.ItemU("Position Belt")
Dim vapPage As Visio.Page = visApp.ActivePage
Dim vshpJohnDoe As Visio.Shape = vapPage.Drop(vmstPositionBelt, 5, 5)
vshpJohnDoe.Name = "John Doe"
vshpJohnDoe.NameU = "Johnny"
vshpJohnDoe.Text = "Wheel Reinventor"
End Sub
Here's what I get:
It may sound really simple, (and it probably is), but I don't want "Name" to appear in the org chart, I want "John Doe" to appear.
<>
CodePudding user response:
vshpJohnDoe.Name = "John Doe" vshpJohnDoe.NameU = "Johnny"
These lines are changes local name (Name) and universal name (NameU) of shape (vshpJohnDoe).
but I don't want "Name" to appear in the org chart
There is some sub-shape's text!
CodePudding user response:
Found the solution myself (with a little help from Google).
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim visApp As New Visio.Application With {
.Visible = True
}
Dim vdocOrgChart As Visio.Document = visApp.Documents.Add("Organization Chart.vst")
Dim vdocShapes As Visio.Document = visApp.Documents("ORGBLT_M.vssx")
Dim vmstPositionBelt As Visio.Master = vdocShapes.Masters.ItemU("Position Belt")
Dim vapPage As Visio.Page = visApp.ActivePage
Dim vshpJohnDoe As Visio.Shape = vapPage.Drop(vmstPositionBelt, 5, 5)
vshpJohnDoe.Name = "John Doe"
vshpJohnDoe.NameU = "Johnny"
vshpJohnDoe.Text = "Wheel Reinventor"
Dim intSect As Integer = Visio.VisSectionIndices.visSectionProp
If vshpJohnDoe.SectionExists(intSect, Visio.VisExistsFlags.visExistsAnywhere) Then
For iRow = 0 To vshpJohnDoe.RowCount(intSect)
If vshpJohnDoe.CellsSRCExists(intSect, iRow, Visio.VisCellIndices.visCustPropsValue, Visio.VisExistsFlags.visExistsAnywhere) Then
Dim vcLabelCell As Visio.Cell = vshpJohnDoe.CellsSRC(intSect, iRow, Visio.VisCellIndices.visCustPropsLabel)
Dim vcValueCell As Visio.Cell = vshpJohnDoe.CellsSRC(intSect, iRow, Visio.VisCellIndices.visCustPropsValue)
Dim strPrompt As String = vcLabelCell.RowNameU
If strPrompt = "Name" Then
vcValueCell.Formula = Chr(34) & "Johann Doe" & Chr(34)
End If
End If
Next
End If
End Sub