3

I want to highlight connectors of a Shape object, but it doesn't give me any LineStyle properties for the connector itself. Here's what I got so far:

    For i = 0 To UBound(lngShapeIDs)
      Dim shp As Shape

      Dim connect As connect
      Set shp = ActivePage.Shapes.ItemFromID(lngShapeIDs(i))
      shp.LineStyle = "Guide"
      shp.BringToFront
      Set connect = shp.FromConnects.Item(i + 1)
    Next 
Ryan Kohn
  • 13,079
  • 14
  • 56
  • 81
Alex
  • 475
  • 1
  • 5
  • 16
  • Could you elaborate on what specific line style properties you would like to set? Knowing that would help direct the answer. – saveenr Aug 28 '12 at 16:49
  • I would like to a) set the line color of the connector and b) bring it to the front. Same thing as with the Shape object, but for the connect. I actually would assume the connector being of a Shape type, as it's just a line - obviously it is not. – Alex Aug 29 '12 at 03:37

1 Answers1

3

Based in your comments this is what I think you are looking for

Dim shape As shape
For Each shape In ActivePage.Shapes
    If (shape.OneD <> 0) Then
        shape.CellsU("LineColor").Formula = "rgb(255,0,0)"
        shape.BringToFront
    End If
Next

This sample enumerates through all the shapes in the page. It assumes and "1-D" shapes are connectors that need to be modified. For those connectors, their line color is set to red and they are each brought to the front.

So if this was the initial state of the drawing:

enter image description here

Then after running the VBA code, the drawing will look like this:

enter image description here

saveenr
  • 8,439
  • 3
  • 19
  • 20
  • Thanks for your answer, this surely works - my problem is, that I don't have the connectors as Shapes, but as Connect objects. They don't have LineColor, unfortunately. – Alex Sep 04 '12 at 09:30
  • Thanks for the answer, documentation about these things is really, really rare and poorly structured – ubugnu Apr 01 '15 at 11:49
  • Starting with Visio 2016 you will get exceptions doing it this way. Instead use FormulaU. – MrZweistein Nov 15 '18 at 15:14