2

As of Build 8201.2025 there has been an unexpected change to the order of events when loading a VSTO addin with a Ribbon in Word.

  • Using Office version 16.0.8067.2115 or older. When loading the addin the following order of events is observed (as has always been the case).

Ribbon_Load event

ThisAddin_Startup event

  • Using Office versions 8201.2025, 8201.2064 or 8201.2075 or newer the order of events is reversed which is an unexpected breaking change.

ThisAddin_Startup event

Ribbon_Load event

  • I have created a simple VSTO Addin using a Visual Designer Ribbon to demonstrate the issue.

>

Public Class Ribbon1
    Private Sub Ribbon1_Load(ByVal sender As System.Object, ByVal e As RibbonUIEventArgs) Handles MyBase.Load

        System.Diagnostics.Debug.Write("Ribbon1_Load event called.")

        'Pass the Ribbon to the Addin.

        ThisAddIn.MyRibbon = Me

    End Sub
End Class

Public Class ThisAddIn

Public Shared Property MyRibbon As Ribbon1 = Nothing

    Private Sub ThisAddIn_Startup() Handles Me.Startup
        Debug.Write("ThisAddin_Startup Called")

        If (MyRibbon Is Nothing) Then
            Debug.Write("MyRibbon is nothing - the ribbon was not captured.")
        Else
            Debug.Write("Ribbon captured successfully.")
        End If

    End Sub
End Class
  • Debug output for 16.0.8067.2115 32 bit

    • [7772] Ribbon1_Load event called.

    • [7772] ThisAddin_Startup Called

    • [7772] Ribbon captured successfully.

  • Debug output for 16.0.8201.2075 32 bit

    • [13556] ThisAddin_Startup Called
    • [13556] MyRibbon is nothing - the ribbon was not captured.
    • [13556] Ribbon1_Load event called

I have posted this up on the Microsoft Support forums however they have stopped responding and since released this version to the Current office channel I need help from the dev community.

Has anyone found a successful workaround? This change of timing is causing alot of problems with how we initialise. It would be ideal for Microsoft Support to provide a solution or workaround until they investigate this bug.

K.G
  • 31
  • 1
  • 8

2 Answers2

1

I always got Ribbon_Load before ThisAddin_Startup because I use Ribbon XML. Ribbon UI allow less controls ... As the both are "entry" points, I suggest you to use only Ribbon1_Load at startup. Or, if you use the Ribbon XML model and you want the very very first entry point, try its constructor

I am not feeling that issue as a bug, to make Word fast many processes are asynchronous. So, in my opinion, the first of ThisAddin_Startup or Ribbon1_Load to start can accidentally change depending on many factors: System performances, Word started alone, Word started via a doc ...

Fabrice T
  • 648
  • 9
  • 23
1

Hope this helps someone! We used the following workaround successfully to work around the changed office load behavior.

Within ThisAddIn_Startup loop until the Ribbon load event has fired and the ribbon is captured.

 While m_oRibbon Is Nothing
        If (timeWaited >= MAX_WAIT_TIME) Then
            Exit Try
        End If

        Threading.Thread.Sleep(50)
        timeWaited = timeWaited + 50
 End While
K.G
  • 31
  • 1
  • 8