Consulting

Results 1 to 7 of 7

Thread: Break mode error messages interrupt loading of ribbon controls

  1. #1
    VBAX Regular
    Joined
    Mar 2017
    Posts
    19
    Location

    Break mode error messages interrupt loading of ribbon controls

    I have created two addins each of which adds a group in the ribbon when PowerPoint is started. The groups contain context sensitive controls which become active when the appropriate object is active in a slide.

    On one machine, when I open PowerPoint with the two addins enabled, every second or third time (it doesn't appear to be entirely consistent), the ribbon controls do not load properly - and I get message boxes popping up saying "PowerPoint can't start this feature because you currently have a Visual Basic for Applications project in break mode." (The message appears 8 times, the first add in ribbon group - Grid maker - appears after 3 error messages, the next one after two more error messages, then there are 3 more error messages to OK).

    This occurs on one Windows 10 machine - with Office 2016 installed, it does not occur on a Windows 10 virtual machine with the same office set up. It occurs with earlier versions of the addin from 3 months ago, which weren't getting those errors at the time. It doesn't seem to occur when just one of the add-ins are enabled.

    It may be that there is some other error on this machine which is causing this problem - however the OS is up to date, and I re-installed Office in case there was a problem - but this made no difference.

    Any pointers to how I could actually be able to find the source of this problem would be great - the error messages aren't really helping, there is extensive error handling in the add-ins, but no error is being logged.


    Ribbon XML Add-in 1:

    <customUI onLoad="gmRibbonUI_onLoad" xmlns="[removed]" xmlns:nsCommtap="Commtap Namespace">
      <ribbon startFromScratch="false">
        <tabs>
          <tab idMso="TabHome">
            <group id="gridMakerGroup" label="Grid maker">
              <button id="gmMakeGrid"
                      label="Make into grid"
                      imageMso="TableInsert"
                      size="normal"
                      onAction="makeGrid"
                      getEnabled="gm_GetEnabled" />
              <button id="gmScaleSelection"
                      label="Scale"
                      imageMso="DrawingCanvasScale"
                      size="normal"
                      onAction="scaleSelection"
                      getEnabled="gm_GetEnabled" />
            </group>
          </tab>
          <tab idQ="nsCommtap:CommtapTools" label="Commtap Tools">
            <group id="CTgridMakerGroup" label="Grid maker">
              <button id="CTgmMakeGrid"
                      label="Make into grid"
                      imageMso="TableInsert"
                      size="normal"
                      onAction="makeGrid"
                      getEnabled="gm_GetEnabled" />
              <button id="CTgmScaleSelection"
                      label="Scale"
                      imageMso="DrawingCanvasScale"
                      size="normal"
                      onAction="scaleSelection"
                      getEnabled="gm_GetEnabled" />
            </group>
          </tab>
        </tabs>
      </ribbon>
    </customUI>
    Ribbon XML for second addin

    <customUI onLoad="csRibbonUI_onLoad" xmlns="[removed]" xmlns:nsCommtap="Commtap Namespace">
      <ribbon startFromScratch="false">
        <tabs>
          <tab idMso="TabHome">
            <group id="commtapSymboliserGroup" label="Commtap Symboliser">
              <button id="csSymboliseForwards" 
                      label="Symbolise"
                      imageMso="ClipArtInsert"
                      size="large"
                      onAction="SymboliseForwards"
                      getEnabled="cs_GetEnabled"
                      keytip="B"/>
              <button id="csSymboliseBackwards"
                      label="Previous"
                      imageMso="MailMergeGoToPreviousRecord"
                      size="normal"
                      onAction="SymboliseBackwards"
                      getEnabled="cs_GetEnabled" />
              <button id="csDefaultPictureSize"
                      label="Default size"
                      imageMso="PivotChartMultipleUnified"
                      size="normal"
                      onAction="defaultSymbolSize"
                      getEnabled="cs_GetEnabled" />
              <button id="csSymboliserPreferences"
                      label="Preferences"
                      imageMso="OrgChartDataOptionsDisplay"
                      size="normal"
                      onAction="symboliserPreferences" />
            </group>
          </tab>
          <tab idQ="nsCommtap:CommtapTools" label="Commtap Tools">
            <!-- Use idQ when creating a tab shared between namespaces - which will be the same so that different add-ins can be on the same tab. -->
            <group id="CTcommtapSymboliserGroup" label="Commtap Symboliser">
              <button id="CTcsSymboliseForwards"
                      label="Symbolise"
                      imageMso="ClipArtInsert"
                      size="large"
                      onAction="SymboliseForwards"
                      getEnabled="cs_GetEnabled"
                      keytip="B"/>
              <button id="CTcsSymboliseBackwards"
                      label="Previous"
                      imageMso="MailMergeGoToPreviousRecord"
                      size="normal"
                      onAction="SymboliseBackwards"
                      getEnabled="cs_GetEnabled" />
              <button id="CTcsDefaultPictureSize"
                      label="Default size"
                      imageMso="PivotChartMultipleUnified"
                      size="normal"
                      onAction="defaultSymbolSize"
                      getEnabled="cs_GetEnabled" />
              <button id="CTcsSymboliserPreferences"
                      label="Preferences"
                      imageMso="OrgChartDataOptionsDisplay"
                      size="normal"
                      onAction="symboliserPreferences" />
            </group>
          </tab>
        </tabs>
      </ribbon>
    </customUI>
    Ribbon loading for first addin:

    Option Explicit
    Option Base 0
    
    
    Dim m_oMyRibbon As IRibbonUI
    Dim m_boolShapeSelected As Boolean
    Dim m_oAppEvents As New CGMApplicationEvents
    
    
    Private Const msMODULE As String = "GMApplicationEventsModule"
    
    
    Function get_m_oMyRibbon() As IRibbonUI
      Set get_m_oMyRibbon = m_oMyRibbon
    End Function
    
    
    Function set_m_boolShapeSelected(value As Boolean)
      m_boolShapeSelected = value
    End Function
    Function get_m_boolShapeSelected() As Boolean
      get_m_boolShapeSelected = m_boolShapeSelected
    End Function
    
    
    Sub gm_GetEnabled(control As IRibbonControl, ByRef returnedVal)
    
    
      Const sSOURCE As String = "gm_GetEnabled"
      On Error GoTo ErrorHandler
      
      returnedVal = True
      
      If control.Id = "gmMakeGrid" Or control.Id = "gmScaleSelection" Then
        returnedVal = GMApplicationEventsModule.get_m_boolShapeSelected
      End If
      ' For Commtap Tools tab:
      If control.Id = "CTgmMakeGrid" Or control.Id = "CTgmScaleSelection" Then
        returnedVal = GMApplicationEventsModule.get_m_boolShapeSelected
      End If
      
    ErrorExit:
      Exit Sub
        
    ErrorHandler:
      If bCentralErrorHandler(msMODULE, sSOURCE, , True) Then
        Stop
        Resume
      Else
        Resume ErrorExit
      End If
    End Sub
    
    
    Sub gmRibbonUI_onLoad(Ribbon As IRibbonUI)
      Set m_oMyRibbon = Ribbon
    End Sub
    
    
    ' Use Auto_Open for storing a reference to the application object
    ' instead of onLoad above.
    Sub Auto_Open()
      Set m_oAppEvents.App = Application
    End Sub
    CGMApplicationEventsClass:

    Option Explicit
    Option Base 0
    
    
    Private Const msMODULE As String = "CGMApplicationEvents"
    
    
    Public WithEvents App As Application
    
    
    Private Sub App_WindowSelectionChange(ByVal Sel As Selection)
    
    
      Const sSOURCE As String = "App_WindowSelectionChange"
      On Error GoTo ErrorHandler
    
    
      If Application.ActiveWindow.Selection.Type <> ppSelectionShapes Then
        GMApplicationEventsModule.set_m_boolShapeSelected False
      Else
        GMApplicationEventsModule.set_m_boolShapeSelected True
      End If
      
      If Not GMApplicationEventsModule.get_m_oMyRibbon Is Nothing Then
      
        Dim oRibbon As IRibbonUI
        Set oRibbon = GMApplicationEventsModule.get_m_oMyRibbon
      
        oRibbon.InvalidateControl "gmMakeGrid"
        oRibbon.InvalidateControl "gmScaleSelection"
      
        ' In the Commtap Tools tab:
        oRibbon.InvalidateControl "CTgmMakeGrid"
        oRibbon.InvalidateControl "CTgmScaleSelection"
      End If
    
    
    ErrorExit:
      Exit Sub
        
    ErrorHandler:
      If bCentralErrorHandler(msMODULE, sSOURCE, , True) Then
        Stop
        Resume
      Else
        Resume ErrorExit
      End If
    
    
    End Sub
    Ribbon loading for second addin:

    Option Explicit
    Option Base 0
    
    
    Public m_oAppEvents As CApplicationEvents
    Private m_boolTextBoxSelected As Boolean
    Private m_boolImageSelected As Boolean
    Private m_oMyRibbon As IRibbonUI
    Private Const msMODULE As String = "ApplicationEventsModule"
    
    
    Sub csRibbonUI_onLoad(Ribbon As IRibbonUI)
      
      Const sSOURCE As String = "csRibbonUI_onLoad"
      On Error GoTo ErrorHandler
      
      Set m_oMyRibbon = Ribbon
      
    ErrorExit:
      Exit Sub
        
    ErrorHandler:
      If bCentralErrorHandler(msMODULE, sSOURCE, , True) Then
        Stop
        Resume
      Else
        Resume ErrorExit
      End If
      
    End Sub
    
    
    ' Use Auto_Open for storing a reference to the application object
    ' instead of onLoad above.
    Sub Auto_Open()
    
      Const sSOURCE As String = "Auto_Open"
      On Error GoTo ErrorHandler
    
    
      If m_oAppEvents Is Nothing Then
        Set m_oAppEvents = Factory.CreateCApplicationEvents
      End If
      Set m_oAppEvents.App = Application
      
    ErrorExit:
      Exit Sub
        
    ErrorHandler:
      If bCentralErrorHandler(msMODULE, sSOURCE, , True) Then
        Stop
        Resume
      Else
        Resume ErrorExit
      End If
      
    End Sub
    
    
    Public Function get_m_oMyRibbon() As IRibbonUI
    
    
      Const sSOURCE As String = "get_m_oMyRibbon"
      On Error GoTo ErrorHandler
    
    
      Set get_m_oMyRibbon = m_oMyRibbon
      
    ErrorExit:
      Exit Function
        
    ErrorHandler:
      If bCentralErrorHandler(msMODULE, sSOURCE, , True) Then
        Stop
        Resume
      Else
        Resume ErrorExit
      End If
      
    End Function
    
    
    Public Function set_m_boolTextBoxSelected(value As Boolean)
      m_boolTextBoxSelected = value
    End Function
    Public Function get_m_boolTextBoxSelected() As Boolean
      get_m_boolTextBoxSelected = m_boolTextBoxSelected
      'get_m_boolTextBoxSelected = True
    End Function
    Public Function set_m_boolImageSelected(value As Boolean)
      m_boolImageSelected = value
    End Function
    Public Function get_m_boolImageSelected() As Boolean
      get_m_boolImageSelected = m_boolImageSelected
      'get_m_boolImageSelected = True
    End Function
    
    
    Sub cs_GetEnabled(Control As IRibbonControl, ByRef returnedVal)
    
    
      returnedVal = True
    
    
      Const sSOURCE As String = "cs_GetEnabled"
      On Error GoTo ErrorHandler
      
      logToFile Control.Id
    
    
      ' On the Home tab:
      If Control.Id = "csSymboliseForwards" Or Control.Id = "csSymboliseBackwards" Then
        returnedVal = ApplicationEventsModule.get_m_boolTextBoxSelected
      ElseIf Control.Id = "csDefaultPictureSize" Then
        returnedVal = ApplicationEventsModule.get_m_boolImageSelected
      End If
      
      ' On the Commtap Tools tab:
      If Control.Id = "CTcsSymboliseForwards" Or Control.Id = "CTcsSymboliseBackwards" Then
        returnedVal = ApplicationEventsModule.get_m_boolTextBoxSelected
      ElseIf Control.Id = "CTcsDefaultPictureSize" Then
        returnedVal = ApplicationEventsModule.get_m_boolImageSelected
      End If
      
    ErrorExit:
      Exit Sub
        
    ErrorHandler:
      If bCentralErrorHandler(msMODULE, sSOURCE, , True) Then
        Stop
        Resume
      Else
        Resume ErrorExit
      End If
    
    
    End Sub
    CApplicationEvents class:

    Option Explicit
    Option Base 0
    
    
    Public WithEvents App As Application
    Private Const msMODULE As String = "CApplicationEvents"
    
    
    Private Sub App_WindowSelectionChange(ByVal Sel As Selection)
      
      Const sSOURCE As String = "App_WindowSelectionChange"
      On Error GoTo ErrorHandler
      
      If Application.ActiveWindow.Selection.Type <> ppSelectionText Then
        ApplicationEventsModule.set_m_boolTextBoxSelected False
      Else
        ApplicationEventsModule.set_m_boolTextBoxSelected True
      End If
      
      If Application.ActiveWindow.Selection.Type <> ppSelectionShapes Then
        ApplicationEventsModule.set_m_boolImageSelected False
      Else
        ApplicationEventsModule.set_m_boolImageSelected True
      End If
      
      If Not ApplicationEventsModule.get_m_oMyRibbon Is Nothing Then
        Dim oRibbon As IRibbonUI
        Set oRibbon = ApplicationEventsModule.get_m_oMyRibbon
      
        ' On the Home tab:
        oRibbon.InvalidateControl "csSymboliseForwards"
        oRibbon.InvalidateControl "csSymboliseBackwards"
        oRibbon.InvalidateControl "csDefaultPictureSize"
      
        ' On the Commtap Tools tab:
        oRibbon.InvalidateControl "CTcsSymboliseForwards"
        oRibbon.InvalidateControl "CTcsSymboliseBackwards"
        oRibbon.InvalidateControl "CTcsDefaultPictureSize"
      End If
    
    
    ErrorExit:
      Exit Sub
        
    ErrorHandler:
      If bCentralErrorHandler(msMODULE, sSOURCE, , True) Then
        Stop
        Resume
      Else
        Resume ErrorExit
      End If
    End Sub

  2. #2
    VBAX Regular
    Joined
    Mar 2017
    Posts
    19
    Location
    If the getEnabled parameter is removed from customUI.xml - then the error messages don't appear;
    If the Auto_Open() sub is commented out - the error messages don't appear;
    Calling "Stop" on the first line of Auto_Open(): the error messages appear *before* reaching this stop statement.

    This then seems to suggest the error is encountered when PowerPoint is last closed, and somehow PowerPoint still retains this in its state when it has re-opened.

    Note, I tried to reproduce the problem with a minimal version of the code above, but was unsuccesful. So the problem may be somehow being created elsewhere. But there is no information from PowerPoint as to where that might be, I just get the message "PowerPoint can't start this feature because you currently have a Visual Basic for Applications project in break mode.", without any further clues.

  3. #3
    VBAX Regular
    Joined
    Mar 2017
    Posts
    19
    Location
    This might not be to do with my add-in:

    My version of Office (2016) was 1707 - update 8326.2096, I reverted it to version 1705 (update 8201.2102) and the problem goes away.

    I also noted this https://answers.microsoft.com/en-us/...=1505060282020

  4. #4
    VBAX Regular
    Joined
    Mar 2017
    Posts
    19
    Location
    This issue still crops up from time to time - and will also go away for no apparent reason - e.g. commenting out a piece of code and then finding the problem has gone away, but then uncommenting out that piece of code - and the problem not re-appearing (!) Anyway, I've posted the problem on msdn (with new information): https://social.msdn.microsoft.com/Fo...point-start-up

  5. #5
    VBAX Wizard
    Joined
    Apr 2007
    Posts
    6,391
    Location
    One thing to try ...

    Word and Excel have a 'Code Cleaner' that exports all modules as text, deletes them, and then imports them

    http://www.appspro.com/Utilities/CodeCleaner.htm


    During the process of creating VBA programs a lot of junk code builds up in your files. If you don't clean your files periodically you will begin to experience strange problems caused by this extra baggage. Cleaning a project involves exporting the contents of all its VBComponents to text files, deleting the components and then importing the components back from the text files.

    You can do the same process manually (export, delete, import) with your powerpoint and see if it gets rid of intermittent errors


    During the process of creating VBA programs a lot of junk code builds up in your files. If you don't clean your files periodically you will begin to experience strange problems caused by this extra baggage. Cleaning a project involves exporting the contents of all its VBComponents to text files, deleting the components and then importing the components back from the text files.
    Paul

    ------------------------------------------------------------------------------------------------------------------------
    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s)
    (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  6. #6
    VBAX Regular
    Joined
    Mar 2017
    Posts
    19
    Location
    I use a version of the code cleaner adapted for PowerPoint: http://www.tushar-mehta.com/powerpoi...aner/index.htm - unfortunately that doesn't solve the problem when it occurs.

  7. #7
    VBAX Regular
    Joined
    Mar 2017
    Posts
    19
    Location
    I have now posted an updated version of this question on stackoverflow: https://stackoverflow.com/questions/...ibbon-controls

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •