I have added a Toggle Button to a Ribbon via the Excel.CustomUI file, which is fine, but it won't actually trigger any callback functions. I've tried various combinations as given on the web, but cannot get any of the functions to run at all.
I also tried with a checkbox, but this did not run functions either. I checked and removed any security, but to no avail.
I have standard buttons which are working as required.
Am missing something?
This is the excel.customUI file
<mso:customUI xmlns:mso='http://schemas.microsoft.com/office/2009/07/customui'
onLoad='ToggleAutoCalc' >
<mso:ribbon>
<mso:qat/>
<mso:tabs>
<mso:tab id='reportTab' label='ICit' insertBeforeQ='mso:TabFormat'>
<mso:group id='reportGroup' label='DBRW Copy Paste' autoScale='true'>
<mso:button id='DBRW Copy' label='DBRW Copy'
imageMso='Copy' onAction='DBRWCopyPaste.xlam!TM1Copy'/>
<mso:button id='DBRW Paste' label='DBRW Paste'
imageMso='Paste' onAction='DBRWCopyPaste.xlam!TM1Paste'/>
<mso:button id='DBRW UnDo' label='DBRW UnDo'
imageMso='CellsDelete' onAction='DBRWCopyPaste.xlam!TM1UndoPaste'/>
**<mso:toggleButton id='AutoCalc' label='AutoCalc'
screentip='Toggle Autocalc'
size='Large'
imageMso='ColumnSettingsMenu' onAction='DBRWCopyPaste.xlam!TbtnToggleAutoCalc'
getPressed='DBRWCopyPaste.xlam!GetPressed'/>**
</mso:group>
</mso:tab>
</mso:tabs>
</mso:ribbon>
</mso:customUI>
and this is my test VBA code:
Option Explicit
Public MyRibbon As IRibbonUI
Sub ToggleAutoCalc(ribbon As IRibbonUI)
Set MyRibbon = ribbon
Debug.Print "ToggleAutoCalc"
End Sub
Sub TbtnToggleAutoCalc(control As IRibbonControl, pressed As Boolean)
pressed = True
End Sub
Sub GetPressed(control As IRibbonControl, ByRef returnedVal)
Dim bAutoCalc As Integer
Dim sVal As String
Dim nVal As Integer
GetPressed = returnedVal
End Sub