title: How to Access Custom Add-In Ribbon Check Box in VBA?
body: <p>I've spent 2 days now trying and searching and nothing seems to be working...</p>
  
  <p>I created a custom ribbon Add-In for Visio in VSTO that installs and buttons work fine.  I just recently added a couple of checkboxes to the ribbon whose states I want to read from within a VBA project.</p>
  
  <p>I can't for the life of me figure out how to access the checkbox state in VBA.  I tried a bunch of things with CommandBars and ToolBars but got nowhere and then I found this walkthrough which seemed promising and followed it to make the Add-In's methods visible to VBA: <a href="https://msdn.microsoft.com/en-us/library/bb608614" rel="nofollow">https://msdn.microsoft.com/en-us/library/bb608614</a></p>
  
  <p>The VBA code does recognize the add-in and I assign the add-in object but when I try to call the object's function (getIOPressedState which refers to the state of one of the checkboxes), I get "object doesn't support this property or method".</p>
  
  <p><strong>Am I missing something here??</strong></p>
  
  <p><b>This is my ribbon class I want to make visible</b></p>
  
  <pre><code>&lt;ComVisible(True)&gt; _
  Public Interface IAddInUtilities
      Function getIOPressed() As Boolean
      Function getDDPressed() As Boolean
      Sub doNothing()
  End Interface
  
  &lt;Runtime.InteropServices.ComVisible(True)&gt; _
  &lt;ClassInterface(ClassInterfaceType.None)&gt; _
  Public Class StructuredAnalysisRibbon
  Implements Office.IRibbonExtensibility, IAddInUtilities
      Public ioPressedState As Boolean = False
      Public ddPressedState As Boolean = False
      Public ribbon As Office.IRibbonUI
  
      Public Function GetCustomUI(ByVal ribbonID As String) As String Implements   Office.IRibbonExtensibility.GetCustomUI
          Return getResourceText("SAVisioAddIn.StructuredAnalysisRibbon.xml")
      End Function
  
      Public Function getIOPressed() As Boolean Implements IAddInUtilities.getIOPressed
          Return ioPressedState
      End Function
  
      Public Function getDDPressed() As Boolean Implements IAddInUtilities.getDDPressed
          Return ddPressedState
      End Function
  
      Public Sub doNothing() Implements IAddInUtilities.doNothing
          'do nothing-added this to see if function As boolean in interface was causing issues
      End Sub
  </code></pre>
  
  <p><b> ThisAddIn.vb </b></p>
  
  <pre><code>Public SARibbon As StructuredAnalysisRibbon
  Protected Overrides Function CreateRibbonExtensibilityObject() As    Microsoft.Office.Core.IRibbonExtensibility
      Return SARibbon
  End Function
  
  Protected Overrides Function RequestComAddInAutomationService() As Object
      If SARibbon Is Nothing Then
          SARibbon = New StructuredAnalysisRibbon
      End If
      Return SARibbon
  End Function
  </code></pre>
  
  <p><b>Visio VBA Code</b></p>
  
  <pre><code>Public Sub bloop()
      Dim addIn As COMAddIn
      Dim addInObject As Object
      Dim ioPressed As Boolean
      ioPressed = False
      Set addIn = Application.COMAddIns.Item("SAVisioAddIn")
      Set addInObject = addIn.Object
  
      ioPressed = addInObject.getIOPressed   'fails here bc method not recognized for object
      'Also tried addIn.Object.doNothing and still didn't work
      If ioPressed = True Then
          MsgBox "checked"
      Else
          MsgBox "not checked"
      End If
  End Sub
  </code></pre>