Solved

Excel Org Charts using VBA - Error Setting Text

Posted on 2007-04-03
2
1,410 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 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 Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

734 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