At work, I occasionally have to modify visio drawings created by others.
When I am making a drawing, I always ensure each segment of a line is a seperate line, which makes modifying later much easier. Unfortunatly few others do it this way and just use polly lines.
The following code found on office-forums.com (and slightly simplified by myself) will split any shapes into individual lines and group them together:
Public Sub ReplaceShapesWithLines() Dim shp As Visio.Shape For Each shp In Visio.ActiveWindow.Selection Call ReplaceShapeWithLines(shp) Next shp End Sub Sub ReplaceShapeWithLines(ByVal shp As Visio.Shape) 'Split multi-segment lines - Assumes just one geomtry section Dim iRow As Integer Dim BeginX As Double Dim EndX As Double Dim BeginY As Double Dim EndY As Double Dim line As Visio.Shape shp.ConvertToGroup For iRow = 2 To shp.RowCount(Visio.visSectionFirstComponent) - 1 BeginX = shp.CellsSRC(Visio.visSectionFirstComponent, iRow - 1, Visio.visX).ResultIU BeginY = shp.CellsSRC(Visio.visSectionFirstComponent, iRow - 1, Visio.visY).ResultIU EndX = shp.CellsSRC(Visio.visSectionFirstComponent, iRow, Visio.visX).ResultIU EndY = shp.CellsSRC(Visio.visSectionFirstComponent, iRow, Visio.visY).ResultIU Set line = shp.DrawLine(BeginX, BeginY, EndX, EndY) Next iRow shp.DeleteSection Visio.visSectionFirstComponent End Sub