I'm stumped. I have a custom ribbon created via the Office RibbonX Editor. I have 3 custom tabs with buttons, and textboxes. These have all been working for 2 months - thanks to the help of many people smarter than me on the web. But now when I open the workbook, I get this error - twice. "Cannot run the macro 'onLoad'. The macro may not be available in this workbook or all macros may be disabled." The custom ribbon loads, but the callbacks also show as unavailable. I have not touched my ribbon module since I got it all working 2 months ago. Anyone have a clue as to what's up?
So I created a new WB and stripped it down to the basics, and it does the same thing. Here is the UI XML:
And here is my ribbon code.
So I created a new WB and stripped it down to the basics, and it does the same thing. Here is the UI XML:
XML:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="onLoad">
<ribbon>
<tabs>
<tab id="MyTab" label="Custom" insertAfterMso="TabHome" >
<group id="grpInputForms" label="Data Entry and Edit">
<button id="btnIncomes" label="Incomes" size="large"
onAction="Inc_Entry" image="Income" />
<button id="btnExpenses" label="Expenses" size="large"
onAction="Exp_Entry" image="Expense" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
And here is my ribbon code.
VBA Code:
Option Explicit
Public RibbonTextBox As String
Public myRibbon As IRibbonUI
'Public MyTag As String
#If VBA7 Then
Public Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef destination As Any, ByRef source As Any, ByVal length As Long)
#Else
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef destination As Any, ByRef source As Any, ByVal length As Long)
#End If
#If VBA7 Then
Function GetRibbon(ByVal lRibbonPointer As LongPtr) As Object
#Else
Function GetRibbon(ByVal lRibbonPointer As Long) As Object
#End If
Dim objRibbon As Object
CopyMemory objRibbon, lRibbonPointer, LenB(lRibbonPointer)
Set GetRibbon = objRibbon
Set objRibbon = Nothing
End Function
'Callback for customUI.onLoad
Sub onLoad(ribbon As IRibbonUI)
Set myRibbon = ribbon
' Store pointer to IRibbonUI
ThisWorkbook.Sheets("Sheet1").Range("C27").Value = ObjPtr(myRibbon)
End Sub
'Callback for Income onAction
Sub Inc_Entry(control As IRibbonControl)
MsgBox "Inc"
End If
End Sub
'Callback for Expenses onAction
Sub Exp_Entry(control As IRibbonControl)
MsgBox "Exp"
End Sub