troubleshooting Question

Customizing MS Word 2007 RibbonX - ComboBox OnChange doesn't fire

Avatar of megnin
megninFlag for United States of America asked on
Microsoft OfficeXMLVisual Basic.NET
4 Comments1 Solution946 ViewsLast Modified:
I'm creating a custom Ribbon menu for MS Word 2007.  I have some working buttons that open specific documents.  I'm having trouble with a ComboBox, however.

For the Buttons, I'm using "OnAction" and for the ComboBox, "OnChange".

The buttons work fine.  The ComboBox does nothing and I can't figure out why.

Here is the Ribbon.xml:

<?xml version="1.0" encoding="utf-8" ?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
  <ribbon startFromScratch="false">
    <tabs>
      <!--<tab idMso="TabHome" >
      <group id="group1" insertAfterMso="GroupClipboard"  label="Document Templates">
      <button id="button1" imageMso="MailMergeAddressBlockInsert" label="WF1 Letterhead" onAction="OnAction" size="normal" />
            <button id="button3" imageMso="MailMergeGreetingLineInsert" label="For Pre-Printed Stock" onAction="OnAction" size="normal" />
            <button id="button4" imageMso="FilePrepareMenu"  label="MEMO Template" onAction="OnAction" size="normal" />
            <button id="button5" imageMso="EnvelopesAndLabelsDialog" label="Envelope Template" onAction="OnAction" size="normal" />
            <button id="button6" imageMso="PageSetupPageDialog" label="FAX Cover Sheet" onAction="OnAction" size="normal" />-->
      <tab id="tab1" label="WorkForce One" >
        <group id="group1" label="Document Templates">
          <button id="button1" imageMso="MailMergeAddressBlockInsert" label="WF1 Letterhead" onAction="OnAction1" size="large" />
          <button id="button3" imageMso="MailMergeGreetingLineInsert" label="For Pre-Printed Stock" onAction="OnAction2" size="large" />
          <button id="button4" imageMso="FilePrepareMenu"  label="MEMO Template" onAction="OnAction3" size="large" />
          <button id="button5" imageMso="EnvelopesAndLabelsDialog" label="Envelope Template" onAction="OnAction4" size="large" />
          <button id="button6" imageMso="PageSetupPageDialog" label="FAX Cover Sheet" onAction="OnAction5" size="large" />

          <comboBox id="ComboBox1" label="Department Memos" onChange="OnChange1" supertip="Select your Department to open the Memo Template">
            <item id="item1" label="Executive" />
            <item id="item2" label="Fiscal" />
            <item id="item3" label="Human Resources" />
            <item id="item4" label="Legal" />
            <item id="item5" label="Communications" />
            <item id="item6" label="Operations" />
            <item id="item7" label="MIS" />
            <item id="item8" label="Quality Assurance" />
            <item id="item9" label="Business Services" />
          </comboBox>

          <dialogBoxLauncher>
            <button id="button99" screentip="Select a Standard WorkForce One Document Template" onAction="OnAction" />
          </dialogBoxLauncher>
        </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

==================================================================
And here is the Connect.vb
==================================================================
Imports Extensibility
Imports System.Runtime.InteropServices
Imports Microsoft.Office.Core
Imports Word = Microsoft.Office.Interop.Word
Imports System.Reflection
Imports System.IO


#Region " Read me for Add-in installation and setup information. "
' When run, the Add-in wizard prepared the registry for the Add-in.
' At a later time, if the Add-in becomes unavailable for reasons such as:
'   1) You moved this project to a computer other than which is was originally created on.
'   2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in.
'   3) Registry corruption.
' you will need to re-register the Add-in by building the $SAFEOBJNAME$Setup project,
' right click the project in the Solution Explorer, then choose install.
#End Region

<GuidAttribute("667C25F7-F791-4A19-A323-7ECD95EF5D86"), ProgIdAttribute("WF1Ribbon.Connect")> _
Public Class Connect
      
    Implements Extensibility.IDTExtensibility2
    Implements IRibbonExtensibility

    Private applicationObject As Word.Application
    Dim addInInstance As Object

    Public Sub OnAction1(ByVal IRibbonControl As Object)
        applicationObject.Documents.Add("S:\Marketing\MSMENU\letterhead.doc")
        Dim NewPath As String
        NewPath = ("F:\")
        My.Computer.FileSystem.CurrentDirectory = NewPath
    End Sub
    Public Sub OnAction2(ByVal IRibbonControl As Object)
        applicationObject.Documents.Add("S:\Marketing\MSMENU\letterheadpre.doc")
        Dim NewPath As String
        NewPath = ("F:\")
        My.Computer.FileSystem.CurrentDirectory = NewPath
    End Sub
    Public Sub OnAction3(ByVal IRibbonControl As Object)
        applicationObject.Documents.Add("S:\Marketing\MSMENU\memo.doc")
        Dim NewPath As String
        NewPath = ("F:\")
        My.Computer.FileSystem.CurrentDirectory = NewPath
    End Sub
    Public Sub OnAction4(ByVal IRibbonControl As Object)
        applicationObject.Documents.Add("S:\Marketing\MSMENU\envelope.doc")
        Dim NewPath As String
        NewPath = ("F:\")
        My.Computer.FileSystem.CurrentDirectory = NewPath
    End Sub
    Public Sub OnAction5(ByVal IRibbonControl As Object)
        applicationObject.Documents.Add("S:\Marketing\MSMENU\fax.doc")
        Dim NewPath As String
        NewPath = ("F:\")
        My.Computer.FileSystem.CurrentDirectory = NewPath
    End Sub
    Public Sub OnChange1(ByVal IRibbonControl As Object)
        applicationObject.Documents.Add("S:\Marketing\MSMENU\memo.doc")

    End Sub

    Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown
    End Sub

    Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnAddInsUpdate
    End Sub

    Public Sub OnStartupComplete(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnStartupComplete
    End Sub

    Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnection
    End Sub

    Public Sub OnConnection(ByVal application As Object, ByVal connectMode As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
        applicationObject = DirectCast(application, Word.Application)
        addInInstance = addInInst
    End Sub

    Public Function GetCustomUI(ByVal RibbonID As String) As String Implements Microsoft.Office.Core.IRibbonExtensibility.GetCustomUI
        Dim asm As Assembly = Assembly.GetExecutingAssembly()
        Dim stream As Stream = asm.GetManifestResourceStream("WF1Ribbon.Ribbon.xml")
        Dim reader As New StreamReader(stream)
        Dim Ribbon As String = reader.ReadToEnd
        reader.Close()
        stream.Close()
        'Return Ribbon

        Return My.Resources.Ribbon
    End Function
End Class
===============================================================

The ComboBox OnChange1 event is at line 58 of Connect.vb.  I just put one action in it to test before I add the logic to open a different document for each selection.

What have I missed?

Thanks.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros