Results 1 to 8 of 8
  1. #1
    Lounger
    Join Date
    Sep 2002
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    texts in diagrams (Excel 2002)

    I run the following code to get the text in Excel diagram. This code is present in Excel help also. However this code gives the error 1004 'Unable to set text property of the characters class' at the 3rd last line .

    shText.TextFrame.Characters.Text = Str(intCount)

    Please tell what to do.
    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

  2. #2
    2 Star Lounger
    Join Date
    Dec 2000
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: texts in diagrams (Excel 2002)

    Have Excel 97 only. Therefore:
    a) Is DiagramNode a new VBA object introduced after Excel 97 ? If not: How did _you_ define it ?
    [img]/forums/images/smilies/cool.gif[/img] Record a macro which does what you want, gives you the right syntax (aside that it uses 'select')

  3. #3
    Lounger
    Join Date
    Sep 2002
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: texts in diagrams (Excel 2002)

    Diagrams is a functionality of Office 2002 only.

    Further record macro does not work opn this functionality . That is a big problem .

    Thanks for yr feedback.

  4. #4
    Lounger
    Join Date
    Sep 2002
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: texts in diagrams (Excel 2002)

    As suggested by cri , I had already tried record macro . But there also was an error when I run the following line .

    ActiveSheet.Shapes.Range(Array("Organization Chart 2", "_s1033")).Select

    Error was 1004 Item with specified name wasn't found.

    Any help. Sample macro code appended here.


    ActiveSheet.Shapes("Organization Chart 2").Select
    ActiveSheet.Shapes("Organization Chart 2").Select
    ActiveSheet.Shapes.Range(Array("Organization Chart 2", "_s1033")).Select
    ActiveSheet.Shapes("Organization Chart 2").Select
    ActiveSheet.Shapes.Range(Array("Organization Chart 2", "_s1032")).Select
    ActiveSheet.Shapes("Organization Chart 2").Select
    ActiveSheet.Shapes.Range(Array("Organization Chart 2", "_s1031")).Select
    ActiveSheet.Shapes("Organization Chart 2").Select
    ActiveSheet.Shapes.Range(Array("Organization Chart 2", "_s1027")).Select
    Selection.Characters.Text = "Hitesh"
    With Selection.Characters(Start:=1, Length:=6).Font
    .Name = "Arial"
    .FontStyle = "Regular"
    .Size = 12
    .Strikethrough = False
    .Superscript = False
    .Subscript = False
    .OutlineFont = False
    .Shadow = False
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
    End With

  5. #5
    2 Star Lounger
    Join Date
    Dec 2000
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: texts in diagrams (Excel 2002)

    I do not know if it does appy here (have Office97), but I always name my shapes myself, the numbering sİheme of Microsoft is a bit difficult to predict/follow.
    http://www.microsoft.com/officedev/a...pg/010/010.htm

  6. #6
    Lounger
    Join Date
    Sep 2002
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: texts in diagrams (Excel 2002)

    Thanks for the reply . I'll go through the web page and see if I can get anything out of it .

    In excel 2002 adddiagram is special method of shapes objects . Record macro does not work completely with these diagrams.

    Nevertheless , thanks for the reply .

  7. #7
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: texts in diagrams (Excel 2002)

    Boy, did that have me confused: your code should work, but it is an Excel bug, see Q317293. The workaround, as shown in Q317293 is to create the diagram in Word and copy it to Excel. What a pain, but at least it works. HTH --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  8. #8
    Lounger
    Join Date
    Sep 2002
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: texts in diagrams (Excel 2002)

    Sammy ,

    Thanks a lot for this reply . As correctly mentioned by you it'slot of pain (but only for computer not me ) . So I am extremely hapyy..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •