none
VSTO - Word 2007 addin with Ribbon not displaying RRS feed

  • Question

  • I am using VS 2010 and have developed an addin for Word 2007.  I originally developed for Word 2010, and everything worked.  I then needed to develop specifically for Word 2007 through Word 2013 so I loaded up VS 2010 with Word 2007 so that I could create/debug a Word 2007 addin.  

    Although the original addin I developed for Word 2010 worked like a charm, it is not working for Word 2007.  No error messages or anything.  The issue is that my ribbon will not display...created as xml, not the designer.  Have added the "CreateRibbonExtensibilityObject" function in the "ThisAddIn.vb" file.  

    Any ideas what I could possibly be doing wrong?  I even striped out my ribbon.xml file to the bare minimum so should not be any issues with the XML itself?

    The following is the code:

    Ribbon1.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load">
      <ribbon>
        <tabs>
          <tab idMso="TabAddIns">
            <group id="MyGroup" label="My Group">
              <button id="btnAddWaterMarkA" label="SE FN CO" imageMso="WatermarkGallery" showImage="true" size="large" screentip="Add Watermark A to this Document" onAction="AddWatermarkAClick" />
            </group>
          </tab>
        </tabs>
      </ribbon>
    </customUI>

    Ribbon1.vb

    <Runtime.InteropServices.ComVisible(True)> _
        Public Class Ribbon1
        Implements Office.IRibbonExtensibility
    
        Private ribbon As Office.IRibbonUI
    
        Public Sub New()
        End Sub
    
        Public Function GetCustomUI(ByVal ribbonID As String) As String Implements Office.IRibbonExtensibility.GetCustomUI
            Return GetResourceText("WordAddIn1.Ribbon1.xml")
        End Function
    
    #Region "Ribbon Callbacks"
        'Create callback methods here. For more information about adding callback methods, select the Ribbon XML item in Solution Explorer and then press F1.
        Public Sub Ribbon_Load(ByVal ribbonUI As Office.IRibbonUI)
            Me.ribbon = ribbonUI
        End Sub
    
        Public Sub AddWatermarkAClick(ByVal control As Office.IRibbonControl)
            If AddWatermark("A") Then
    
            End If
        End Sub
    
    
    #End Region
    
    #Region "Helpers"
    
        Private Shared Function GetResourceText(ByVal resourceName As String) As String
            Dim asm As Reflection.Assembly = Reflection.Assembly.GetExecutingAssembly()
            Dim resourceNames() As String = asm.GetManifestResourceNames()
            For i As Integer = 0 To resourceNames.Length - 1
                If String.Compare(resourceName, resourceNames(i), StringComparison.OrdinalIgnoreCase) = 0 Then
                    Using resourceReader As IO.StreamReader = New IO.StreamReader(asm.GetManifestResourceStream(resourceNames(i)))
                        If resourceReader IsNot Nothing Then
                            Return resourceReader.ReadToEnd()
                        End If
                    End Using
                End If
            Next
            Return Nothing
        End Function
    
    #End Region
    
    End Class
    

    ThisAddin.vb

    Public Class ThisAddIn
    
        Private Sub ThisAddIn_Startup() Handles Me.Startup
    
        End Sub
    
        Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
    
        End Sub
        Public Shared Function AddWatermark(ByVal strType As String) As Boolean
            
        End Function
        Protected Overrides Function CreateRibbonExtensibilityObject() As Microsoft.Office.Core.IRibbonExtensibility
            Return New Ribbon1()
        End Function
    End Class
    

    Any ideas on why the ribbon is not showing in Word 2007 when this..almost..same code worked for Word 2010?

    Thanks!


    Monday, December 22, 2014 6:24 PM

Answers

  • Hi,  I have been able to finally solve the issue.  I applied the updates for Office, among others.  This was a new VM and I had not ran the Windows Update on it to get all updates.  So one of the updates seemed to correct the issue.

    Have a great day!

    • Marked as answer by Voyagr12 Tuesday, December 23, 2014 11:17 AM
    Tuesday, December 23, 2014 11:16 AM

All replies

  • Hi Voyagr,

    >> it is not working for Word 2007.  No error messages or anything.  The issue is that my ribbon will not display...created as xml, not the designer<<

    Did this issue occur when you run the project in Visual Studio and the ribbon didn't display when use ribbon XML?

    I am trying to reproduce the issue however failed. Here are the steps:
    1. Create Word 2007 add-in in Visual Studio 2008

    2. Add Ribbon XML item

    3. Copy the Ribbon1.xml above to override the default

    4. Copy the AddWartemark and CreateRibbonExtensibilityObject sub into ThisAddin.vb

    The ribbon display successfully:

    Did I miss any step? Did you install Office 2010 and Office 2007 on the same computer?

    If I understood correctly, I suggest that you try to run the project only install Office 2007. If the issue still exits, you can upload the sample project to OneDrive and please remove the sensitive information before you uploading.

    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.

    Tuesday, December 23, 2014 2:27 AM
    Moderator
  • Hi,  I have been able to finally solve the issue.  I applied the updates for Office, among others.  This was a new VM and I had not ran the Windows Update on it to get all updates.  So one of the updates seemed to correct the issue.

    Have a great day!

    • Marked as answer by Voyagr12 Tuesday, December 23, 2014 11:17 AM
    Tuesday, December 23, 2014 11:16 AM