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="GroupClipb
oard" label="Document Templates">
<button id="button1" imageMso="MailMergeAddress
BlockInser
t" label="WF1 Letterhead" onAction="OnAction" size="normal" />
<button id="button3" imageMso="MailMergeGreetin
gLineInser
t" 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="EnvelopesAndLabe
lsDialog" label="Envelope Template" onAction="OnAction" size="normal" />
<button id="button6" imageMso="PageSetupPageDia
log" label="FAX Cover Sheet" onAction="OnAction" size="normal" />-->
<tab id="tab1" label="WorkForce One" >
<group id="group1" label="Document Templates">
<button id="button1" imageMso="MailMergeAddress
BlockInser
t" label="WF1 Letterhead" onAction="OnAction1" size="large" />
<button id="button3" imageMso="MailMergeGreetin
gLineInser
t" 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="EnvelopesAndLabe
lsDialog" label="Envelope Template" onAction="OnAction4" size="large" />
<button id="button6" imageMso="PageSetupPageDia
log" 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.InteropServ
ices
Imports Microsoft.Office.Core
Imports Word = Microsoft.Office.Interop.W
ord
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-F
791-4A19-A
323-7ECD95
EF5D86"), ProgIdAttribute("WF1Ribbon
.Connect")
> _
Public Class Connect
Implements Extensibility.IDTExtensibi
lity2
Implements IRibbonExtensibility
Private applicationObject As Word.Application
Dim addInInstance As Object
Public Sub OnAction1(ByVal IRibbonControl As Object)
applicationObject.Document
s.Add("S:\
Marketing\
MSMENU\let
terhead.do
c")
Dim NewPath As String
NewPath = ("F:\")
My.Computer.FileSystem.Cur
rentDirect
ory = NewPath
End Sub
Public Sub OnAction2(ByVal IRibbonControl As Object)
applicationObject.Document
s.Add("S:\
Marketing\
MSMENU\let
terheadpre
.doc")
Dim NewPath As String
NewPath = ("F:\")
My.Computer.FileSystem.Cur
rentDirect
ory = NewPath
End Sub
Public Sub OnAction3(ByVal IRibbonControl As Object)
applicationObject.Document
s.Add("S:\
Marketing\
MSMENU\mem
o.doc")
Dim NewPath As String
NewPath = ("F:\")
My.Computer.FileSystem.Cur
rentDirect
ory = NewPath
End Sub
Public Sub OnAction4(ByVal IRibbonControl As Object)
applicationObject.Document
s.Add("S:\
Marketing\
MSMENU\env
elope.doc"
)
Dim NewPath As String
NewPath = ("F:\")
My.Computer.FileSystem.Cur
rentDirect
ory = NewPath
End Sub
Public Sub OnAction5(ByVal IRibbonControl As Object)
applicationObject.Document
s.Add("S:\
Marketing\
MSMENU\fax
.doc")
Dim NewPath As String
NewPath = ("F:\")
My.Computer.FileSystem.Cur
rentDirect
ory = NewPath
End Sub
Public Sub OnChange1(ByVal IRibbonControl As Object)
applicationObject.Document
s.Add("S:\
Marketing\
MSMENU\mem
o.doc")
End Sub
Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibi
lity2.OnBe
ginShutdow
n
End Sub
Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibility.IDTExtensibi
lity2.OnAd
dInsUpdate
End Sub
Public Sub OnStartupComplete(ByRef custom As System.Array) Implements Extensibility.IDTExtensibi
lity2.OnSt
artupCompl
ete
End Sub
Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_Disconne
ctMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibi
lity2.OnDi
sconnectio
n
End Sub
Public Sub OnConnection(ByVal application As Object, ByVal connectMode As Extensibility.ext_ConnectM
ode, ByVal addInInst As Object, ByRef custom As System.Array) Implements Extensibility.IDTExtensibi
lity2.OnCo
nnection
applicationObject = DirectCast(application, Word.Application)
addInInstance = addInInst
End Sub
Public Function GetCustomUI(ByVal RibbonID As String) As String Implements Microsoft.Office.Core.IRib
bonExtensi
bility.Get
CustomUI
Dim asm As Assembly = Assembly.GetExecutingAssem
bly()
Dim stream As Stream = asm.GetManifestResourceStr
eam("WF1Ri
bbon.Ribbo
n.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.
Start Free Trial