Solved

VB.net formatting of connector types

Posted on 2014-02-11
4
830 Views
Last Modified: 2014-02-24
I'm building a a chart in powerpoint using VB.net.  Here is one function to build a chart:

 Sub addFAChart(FA As String, ByRef rsMO As ADODB.Recordset, coIRPL As IRPL)

        Dim pptSlide As Microsoft.Office.Interop.PowerPoint.Slide
        Dim rsCO As ADODB.Recordset
        Dim oSALayout As SmartArtLayout
        Dim QNode As SmartArtNode
        Dim levelThreeQNode As SmartArtNode
        Dim QNodes As SmartArtNodes
        Dim oShp As Microsoft.Office.Interop.PowerPoint.Shape

        pptSlide = addSlide(PpSlideLayout.ppLayoutText)

        oSALayout = pptPowerPointApp.SmartArtLayouts(105) 'reference to organization chart

        oShp = pptSlide.Shapes.AddSmartArt(oSALayout, 0.42 * 72, 0.33 * 72, 6.75 * 72, 11.0 * 72)


        QNodes = oShp.SmartArt.AllNodes
        For i = 1 To 5      'delete all included nodes
            oShp.SmartArt.AllNodes(1).Delete()
        Next

        oShp.SmartArt.AllNodes(1).TextFrame2.TextRange.Text = FA
        oShp.SmartArt.AllNodes(1).Shapes.Fill.ForeColor.RGB = RGB(185, 205, 229)
        oShp.SmartArt.AllNodes(1).Shapes.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(0, 0, 0)


        Do While Not rsMO.EOF

            QNode = oShp.SmartArt.AllNodes.Add


            QNode.TextFrame2.TextRange.Text = "MO " & rsMO.AbsolutePosition & ": " & rsMO.Fields("title").Value

            QNode.Shapes.Fill.ForeColor.RGB = RGB(166, 166, 166)
            QNode.Shapes.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(0, 0, 0)

            rsCO = coIRPL.getCO("[Major Objective] ='" & rsMO.Fields("Major Objective").Value & "'")

            Do While Not rsCO.EOF

                levelThreeQNode = QNode.AddNode(Microsoft.Office.Core.MsoSmartArtNodePosition.msoSmartArtNodeBelow)

                levelThreeQNode.TextFrame2.TextRange.Text = "CO " & rsCO.AbsolutePosition & ": " & rsCO.Fields("title").Value

                levelThreeQNode.Shapes.Fill.ForeColor.RGB = RGB(162, 192, 162)

                levelThreeQNode.Shapes.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(0, 0, 0)


                levelThreeQNode = Nothing

                rsCO.MoveNext()
            Loop

            rsCO = Nothing

            rsMO.MoveNext()
        Loop

       

    End Sub

Open in new window


The connector types in the smart art come out as diagonal lines... i'd like them to be elbow connectors.  How do I format the connectors in the smartart?  I'd also like to change the color but just can't figure out the namespace/class/method path.
0
Comment
Question by:HyperBPP
[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
4 Comments
 
LVL 22

Expert Comment

by:plusone3055
ID: 39850642
here is a youtube video for working in smartart to format lines and colors.
its for the office side but works just the same in powerpoint smartart

http://www.youtube.com/watch?v=ulHbVDe_5RA
0
 
LVL 23

Expert Comment

by:JSRWilson
ID: 39851234
I am pretty sure there is no way to make the "connectors" elbow connectors.
0
 
LVL 6

Author Comment

by:HyperBPP
ID: 39856755
Well, maybe elbow is the wrong word... But I want them to have those 90 degree angles rather than be diagnol.  The first post is a video for doing it manually.  I need to do it via code.

Thanks!
0
 
LVL 23

Accepted Solution

by:
JSRWilson earned 500 total points
ID: 39880636
I'm not using VB.Net (vba) and no database but my code should (I think) do the same as your's more or less. I DON'T get diagonal connectors

JUST REALISED I HAVE CUSTOM Smart Art and my layout 105 is not your 105! Rechecking  but I think there's no way to change the connector shape in that layout. Maybe try layout 103?

This is the test vba I used:

Sub sa()
Dim osld As Slide
Dim oLay As SmartArtLayout
Dim oSA As Shape
Dim qNode As SmartArtNode
Dim level3node As SmartArtNode
Dim i As Long
Dim x As Integer
For i = 1 To Application.SmartArtLayouts.Count
If Application.SmartArtLayouts(i).Name = "Horizontal Organization Chart" Then Exit For
Next
Set oLay = Application.SmartArtLayouts(i) '103 normally
Debug.Print oLay.Name
Set osld = ActivePresentation.Slides(1)
Set oSA = osld.Shapes.AddSmartArt(oLay, 0.42 * 72, 0.33 * 72, 6.75 * 72, 11 * 72)
Dim oshp As Shape

While oSA.SmartArt.AllNodes.Count > 0
oSA.SmartArt.AllNodes(1).Delete
Wend

For i = 1 To 2
Set qNode = oSA.SmartArt.AllNodes.Add
qNode.Shapes(1).TextFrame2.TextRange = "TEST"
For x = 1 To 3
Set level3node = qNode.AddNode(msoSmartArtNodeBelow)
level3node.TextFrame2.TextRange = "LEVEL"
level3node.Shapes.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(0, 0, 255)
level3node.Shapes.Fill.ForeColor.RGB = RGB(255, 0, 0)
Next x
Next i
'The only way I know to recolour connectors
For i = 1 To oSA.GroupItems.Count
Set oshp = oSA.GroupItems(i)
If oshp.Type = msoLine Then
oshp.Line.ForeColor.RGB = vbRed
End If
Next
End Sub

Open in new window

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Outline From PowerPoint 2010 it is possible to have shapes appear in front of video, in earlier versions video always played in front of other shapes. This means it is possible to have captions animated to appear in front of video. Users who h…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video teaches viewers how to add transitions to their Slideshows and how to set up timing for the transitions.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

730 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