?
Solved

Excel Org Charts using VBA - Error Setting Text

Posted on 2007-04-03
2
Medium Priority
?
1,416 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

752 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