Visio Guy

Visio Discussions => Programming & Code => Topic started by: vittorioe89 on April 14, 2014, 08:59:52 PM

Title: Help with DropManyLinked method [2010 Professional]
Post by: vittorioe89 on April 14, 2014, 08:59:52 PM
As a newb to VBA, I am having some trouble executing the DropManyLinked method to meet my purposes. I am trying to create a roadmap for a portfolio of projects using timelines. Using the code below, I have been able to drop the linked shapes for just one project/row in the data list. My sticking point is how to go about modifying this code to create the same dropped shapes for every project/row. I know I need to do a loop of some kind.

Any help would be greatly appreciated.

Sub DropManyLinkedU_Roadmap()

    Dim avarObjects(0 To 4) As Variant
    Dim adblXYs(0 To 9) As Double
    Dim alngDataRowIDs(0 To 4) As Long
    Dim alngShapeIDs() As Long
    Dim vsoDataRecordset As Visio.DataRecordset
    Dim intRecordesetCount As Integer
    Dim lngReturned As Long
    Dim intCounter As Integer
    Dim intObjectNumber As Integer
       
    intRecordsetCount = Visio.ActiveDocument.DataRecordsets.Count
    Set vsoDataRecordset = Visio.ActiveDocument.DataRecordsets(intRecordsetCount)
   
    For intObjectNumber = 0 To 4
     Set avarObjects(0) = Visio.Documents("Roadmap Stencil.VSS").Masters("Timeline")
     Set avarObjects(1) = Visio.Documents("Roadmap Stencil.VSS").Masters("Phase 0")
     Set avarObjects(2) = Visio.Documents("Roadmap Stencil.VSS").Masters("Phase 1")
     Set avarObjects(3) = Visio.Documents("Roadmap Stencil.VSS").Masters("Phase 2")
     Set avarObjects(4) = Visio.Documents("Roadmap Stencil.VSS").Masters("Deploy")
    Next

    adblXYs(0) = 2
    adblXYs(1) = 2
    adblXYs(2) = 4
    adblXYs(3) = 4
    adblXYs(4) = 6
    adblXYs(5) = 6
       
    alngDataRowIDs(0) = 45
    alngDataRowIDs(1) = 45
    alngDataRowIDs(2) = 45
    alngDataRowIDs(3) = 45
    alngDataRowIDs(4) = 45

    lngReturned = ActivePage.DropManyLinkedU(avarObjects, adblXYs, vsoDataRecordset.ID, alngDataRowIDs, True, alngShapeIDs)
    Debug.Print lngReturned
   
    For intCounter = 0 To lngReturned - 1
        Debug.Print alngShapeIDs(intCounter)
    Next
   
End Sub