none
Visio 2010: Manage flowchart swimlane via code RRS feed

  • Question

  • I'm working with flowcharts and need to create them via code.  I'm using VBA for now.  I can drop my first swimlane on the page, no problem.  But when I need to add a second (using the Page.Drop method), the swimlane isn't added to the existing CFF Container.  I've tried using the CFF Container's drop method to add a swimlane but that doesn't work either.  And I also need to set the text for the swimlane header via code.  Anyone know how to do this in Visio 2010?
    Wednesday, September 7, 2011 8:23 PM

Answers

  • Hi Ira Davis,

    Thank you for your detailed information and I can reproduce the problem on my side.

    I try to modify the code to use DropIntoList method which can add the third swimlane to the CFF container, below is the VBA macro:

    Sub TestApp()

    Dim shp As Shape

    Dim targetList As Shape

    Dim pos As Integer

    Dim objToDrop

    Set objToDrop = Application.ActiveDocument.Masters("Swimlane (vertical)")

    Set targetList = Application.ActivePage.Shapes.ItemFromID(4)

    Set shp = Application.ActivePage.DropIntoList(objToDrop, targetList, 4)

    End Sub

    Hope this can help you and just feel free to follow up after you have tried.Wish you a nice day.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Bruce Song Tuesday, September 13, 2011 8:33 AM
    • Marked as answer by Bruce Song Thursday, September 15, 2011 3:55 AM
    Monday, September 12, 2011 3:18 AM
  • This will work.  For those reading this thread the object "targetList" is a "Swimlane List".  You can read about lists and containers (new in Visio 2010) here:

    http://social.msdn.microsoft.com/Forums/en-US/visiogeneral/thread/784d8169-5b22-4a52-9198-33ebac0dc057

     

    One other item:  How can I set the text of the swimlane header via code?  Setting the User.visHeadingText property's formula doesn't work.

    • Marked as answer by Ira Davis Tuesday, September 13, 2011 3:29 PM
    Monday, September 12, 2011 10:02 PM

All replies

  • Hi Ira Davis,

    Thank you for posting.

    After reading your post, I tried to produce the scenario on my side, but I found it to make it. So, could you show me the reproducible steps about your problem and it will be appreciate if you can send me a copy of your visio file. You can send it via my email

    v-bpeng@microsoft.com

    I am not very sure whether you have use the Page.Drop method correctly, here is the article on MSDN about the method:

    http://msdn.microsoft.com/en-us/library/ms195970(office.12).aspx

    And here is another article about adding shapes:

    http://msdn.microsoft.com/en-us/library/cc160744.aspx

    Hope this can give you some hint and I will do further research with your detailed information. Wish  you a nice day.

    Best Regards,

     


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, September 9, 2011 5:11 AM
  • Create a new cross functional flowchart (US units).  The one I create comes up in portrait with two swimlanes predefined.  Add this code to the "ThisDocument" VBA.  I arrived a the x and y coordinates from examining the shapesheet of the leftmost swimlane.  When the macro is run, you won't get another swimlane added to the existing flowchart but a second CFF Container with a swimlane and the Y position will be something like 14.5.

     

    Sub TestApp()
        Dim VPage As Visio.Page
        Dim VMaster As Visio.Master
        Dim VShape As Visio.Shape
       
        Set VPage = Application.ActiveDocument.Pages(1)
        Set VMaster = Application.ActiveDocument.Masters("Swimlane (vertical)")
        'Set VShape = VPage.Drop(VMaster, 4.25, 5.25)
        VPage.Drop VMaster, 4.25, 5.25
    End Sub

    Friday, September 9, 2011 12:50 PM
  • Hi Ira Davis,

    Thank you for your detailed information and I can reproduce the problem on my side.

    I try to modify the code to use DropIntoList method which can add the third swimlane to the CFF container, below is the VBA macro:

    Sub TestApp()

    Dim shp As Shape

    Dim targetList As Shape

    Dim pos As Integer

    Dim objToDrop

    Set objToDrop = Application.ActiveDocument.Masters("Swimlane (vertical)")

    Set targetList = Application.ActivePage.Shapes.ItemFromID(4)

    Set shp = Application.ActivePage.DropIntoList(objToDrop, targetList, 4)

    End Sub

    Hope this can help you and just feel free to follow up after you have tried.Wish you a nice day.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Bruce Song Tuesday, September 13, 2011 8:33 AM
    • Marked as answer by Bruce Song Thursday, September 15, 2011 3:55 AM
    Monday, September 12, 2011 3:18 AM
  • This will work.  For those reading this thread the object "targetList" is a "Swimlane List".  You can read about lists and containers (new in Visio 2010) here:

    http://social.msdn.microsoft.com/Forums/en-US/visiogeneral/thread/784d8169-5b22-4a52-9198-33ebac0dc057

     

    One other item:  How can I set the text of the swimlane header via code?  Setting the User.visHeadingText property's formula doesn't work.

    • Marked as answer by Ira Davis Tuesday, September 13, 2011 3:29 PM
    Monday, September 12, 2011 10:02 PM
  • Hi Ira Dvis,

    Glad to hear that the code works for you. Since the initial problem is resolved, I suggest you open a new thread about your new problem. In this way, other experts can focus on one thread about your new problem and give your suggestions or workarounds and this can also make it be searched easily by others who have this similar problem.

    You can still open a new thread in this fourm.Thank you for your understanding.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, September 13, 2011 8:33 AM