pennypearce
asked on
Customising the Word 2007 Ribbon ersetting combobox after selection
Hi,
I am cutomising the ribbon in Word 2007 to have a combobox on a new tab where users can select an item and it inserts Autotext (or building blocks as they are now called) into the document. I have written the XML and the requisite VBA to do all this and it is working well. The last hurdle however is that if they select the same item in the combobox a second time, the code to insert the AutoText is not triggered. To overcome this I am trying to reset the combobox selection to "nothing" or "blank" once the AutoText is inserted. I used to be able to use control.listitem=-1, but can't get this to work.
I tried adding a "blank" entry to the list so I could select it, but can't get this to work either. Not sure what the InvalidateControl does, but obviously not what I want.
Thanks,
Penny
I am cutomising the ribbon in Word 2007 to have a combobox on a new tab where users can select an item and it inserts Autotext (or building blocks as they are now called) into the document. I have written the XML and the requisite VBA to do all this and it is working well. The last hurdle however is that if they select the same item in the combobox a second time, the code to insert the AutoText is not triggered. To overcome this I am trying to reset the combobox selection to "nothing" or "blank" once the AutoText is inserted. I used to be able to use control.listitem=-1, but can't get this to work.
I tried adding a "blank" entry to the list so I could select it, but can't get this to work either. Not sure what the InvalidateControl does, but obviously not what I want.
Thanks,
Penny
'Callback for Tables onChange
Sub AddTable(control As IRibbonControl, text As String)
Dim aTemplate As Template
Dim BBTemplate As Template
For Each aTemplate In Templates
If aTemplate.Name = "MyOwnBldgBlocks.dotx" Then
Set BBTemplate = aTemplate
Exit For
End If
Next aTemplate
Select Case text
Case " "
Exit Sub
Case "2 col table"
BBTemplate.BuildingBlockEntries("2_pg").Insert Where _
:=Selection.Range, RichText:=True
Case "6 col table"
BBTemplate.BuildingBlockEntries("6_pg").Insert Where _
:=Selection.Range, RichText:=True
Case "8 col table"
BBTemplate.BuildingBlockEntries("8_pg").Insert Where _
:=Selection.Range, RichText:=True
End Select
MyRibbon.InvalidateControl ("Tables")
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window