Solved

Excel Org Charts using VBA - Error Setting Text

Posted on 2007-04-03
2
1,396 Views
Last Modified: 2012-08-14
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.AddDiagram _
        (Type:=msoDiagramRadial, Left:=10, Top:=15, _
        Width:=400, Height:=475)
    Set nodRoot = shDiagram.DiagramNode.Children.AddNode

    ' 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.Children.Item(1).TextShape
        shText.TextFrame.Characters.Text = Str(intcount)
    Next intCount

End Sub
      


This line:         shText.TextFrame.Characters.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
0
Comment
Question by:Link-HRSystems
2 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 18842348
This is a known bug in Excel 2002, so I would have to guess that they probably haven't fixed it in 2003 based on what you say. The workaround, if you can call it that, is, believe it or not, to automate Word or Powerpoint!
See this MSKB article: http://support.microsoft.com/kb/317293
Regards,
Rory
0
 

Author Comment

by:Link-HRSystems
ID: 18844327
thanks, this has got me a little further so will give it a go.  
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This is about my first experience with programming Arduino.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now