Link-HRSystems
asked on
Excel Org Charts using VBA - Error Setting Text
Hi All,
I'm trying to Build an org chart using Excel and VBA but can't even get the example from msdn to work.
Using Excel 2003 + 2007 File Convertor compatibilty pack (saving as .xlsm)
Example Code:
TextShape Property
Returns a Shape object representing the shape of the text box associated with a diagram node.
expression.TextShape
expression Required. An expression that returns one of the objects in the Applies To list.
Example
The following example adds child nodes to a parent node, and displays text in the parent node indicating the number of child nodes created.
Sub CountChildNodes()
Dim nodRoot As DiagramNode
Dim shDiagram As Shape
Dim intCount As Integer
Dim shText As Shape
Set shDiagram = ActiveSheet.Shapes.AddDiag ram _
(Type:=msoDiagramRadial, Left:=10, Top:=15, _
Width:=400, Height:=475)
Set nodRoot = shDiagram.DiagramNode.Chil dren.AddNo de
' Add 3 child nodes to the root node.
For intCount = 1 To 3
nodRoot.Children.AddNode
Next
' Change text in node.
For intCount = 1 To 4
Set shText = shDiagram.DiagramNode.Chil dren.Item( 1).TextSha pe
shText.TextFrame.Character s.Text = Str(intcount)
Next intCount
End Sub
This line: shText.TextFrame.Character s.Text = Str(intcount)
Casues: Run-time error '1004' Unable to set the Text property of the Characters Class
I just want to be able to set the text for a node after it has been created.
Thanks
I'm trying to Build an org chart using Excel and VBA but can't even get the example from msdn to work.
Using Excel 2003 + 2007 File Convertor compatibilty pack (saving as .xlsm)
Example Code:
TextShape Property
Returns a Shape object representing the shape of the text box associated with a diagram node.
expression.TextShape
expression Required. An expression that returns one of the objects in the Applies To list.
Example
The following example adds child nodes to a parent node, and displays text in the parent node indicating the number of child nodes created.
Sub CountChildNodes()
Dim nodRoot As DiagramNode
Dim shDiagram As Shape
Dim intCount As Integer
Dim shText As Shape
Set shDiagram = ActiveSheet.Shapes.AddDiag
(Type:=msoDiagramRadial, Left:=10, Top:=15, _
Width:=400, Height:=475)
Set nodRoot = shDiagram.DiagramNode.Chil
' Add 3 child nodes to the root node.
For intCount = 1 To 3
nodRoot.Children.AddNode
Next
' Change text in node.
For intCount = 1 To 4
Set shText = shDiagram.DiagramNode.Chil
shText.TextFrame.Character
Next intCount
End Sub
This line: shText.TextFrame.Character
Casues: Run-time error '1004' Unable to set the Text property of the Characters Class
I just want to be able to set the text for a node after it has been created.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER