none
Visio Connector Mode enable programmatically RRS feed

  • Question

  • Hello All,

    There are two different things I would like to do.

    1. Add the Connector button to a custom ribbon tab (and group).
    I have tried looking through myRibbon.Tabs list, and I only get the custom tabs. I can't seem to find a collection including the builtin tabs. Is there one, and if so, how do I programmatically traverse it?

    2. Enable the Connector button programmatically.
    I would like to be able to activate the Connector Mode so that the user can then draw connections among objects. I looked at Application.ConnectorToolDataObject, but that appears to be the type of object used, not the mode itself.

    For the record, I am familiar with C#, VB.NET, and VBA, but can usually guess my way through just about any .NET framework language, so feel free to use whatever you are most familiar with.

    Thanks!

    Thursday, May 7, 2015 7:10 PM

Answers

  • Hi,

    >>1. Add the Connector button to a custom ribbon tab (and group).
    I have tried looking through myRibbon.Tabs list, and I only get the custom tabs. I can't seem to find a collection including the builtin tabs. Is there one, and if so, how do I programmatically traverse it?<<

    Does the 'Connect button' means Connector control on the Home->Tools->Connector? Did you want to it to custom tabs?

    If I understand correctly, we need to custom the ribbon with ribbon XML. You can get more detail about ribbon customization from link below:
    Ribbon Overview

    And here is XML for your reference:

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load" loadImage="Image_Load"> 
      <ribbon>
        <tabs>
          <tab idMso="TabAddIns">
            <group id="MyGroup"
                   label="My Group">
              <control idMso="ConnectorTool"/>
            </group>
          </tab>
        </tabs>
      </ribbon>
      <</customUI>

    >>2. Enable the Connector button programmatically.
    I would like to be able to activate the Connector Mode so that the user can then draw connections among objects. I looked at Application.ConnectorToolDataObject, but that appears to be the type of object used, not the mode itself.<<

    We use Application.DoCmd to perform the command. For this scenario, we can use code below to achieve the goal:

     public void buttonConnector_Click(Office.IRibbonControl control)
            {
                Globals.ThisAddIn.Application.DoCmd((short)VisUICmds.visCmdAutoConnectToggle);
            }
    If I misunderstood, please feel free to let me know.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, May 8, 2015 8:36 AM
    Moderator

All replies

  • Hi,

    >>1. Add the Connector button to a custom ribbon tab (and group).
    I have tried looking through myRibbon.Tabs list, and I only get the custom tabs. I can't seem to find a collection including the builtin tabs. Is there one, and if so, how do I programmatically traverse it?<<

    Does the 'Connect button' means Connector control on the Home->Tools->Connector? Did you want to it to custom tabs?

    If I understand correctly, we need to custom the ribbon with ribbon XML. You can get more detail about ribbon customization from link below:
    Ribbon Overview

    And here is XML for your reference:

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load" loadImage="Image_Load"> 
      <ribbon>
        <tabs>
          <tab idMso="TabAddIns">
            <group id="MyGroup"
                   label="My Group">
              <control idMso="ConnectorTool"/>
            </group>
          </tab>
        </tabs>
      </ribbon>
      <</customUI>

    >>2. Enable the Connector button programmatically.
    I would like to be able to activate the Connector Mode so that the user can then draw connections among objects. I looked at Application.ConnectorToolDataObject, but that appears to be the type of object used, not the mode itself.<<

    We use Application.DoCmd to perform the command. For this scenario, we can use code below to achieve the goal:

     public void buttonConnector_Click(Office.IRibbonControl control)
            {
                Globals.ThisAddIn.Application.DoCmd((short)VisUICmds.visCmdAutoConnectToggle);
            }
    If I misunderstood, please feel free to let me know.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, May 8, 2015 8:36 AM
    Moderator
  • Nailed everything I was asking for. Thanks a lot, and it works perfectly with one modification: visCmdDRConnectorTool instead of visCmdAutoConnectToggle
    Friday, May 8, 2015 5:36 PM