I have an XLSM with a customUI ribbon tab to be distributed to users. I will issue code updates via a New.XLSM. All code being executed is no New.XLSM. I have an Update button on the tab, that the user will invoke, which calls one sub –“Run Update”.
I can verify that the sub completes.
The problem is after it completes. After the “completed” message is displayed, it immediately raises the following error:
“Method “InvalidateControl” of IRibbonUI failed.”
It raises this error on all controls that have a getText callback – 2 editboxes and 1 label. If I click End, the file crashes and closed. The values of those controls are stored in a worksheet. I can change the editboxes all day long and run all the other ribbon controls as well without issue. The Update sub does not touch any ribbon controls, other than being called from the Update button. Here is the code for one editbox, and similar to the other textbox.
“User Input” is an xlVeryHidden sheet. MyRibbon is set in the ribbon load callback
I have looked all over for solutions, but not finding anything. Does anyone have any ideas why this is happening or can offer some troubleshooting ideas?
VBA Code:
Sub Run_Update()
'Asks user to open the Existing XLSM
'Performs several validations
'Saves a backup of Existing.XLSM, although it does not alter that file at all
'A modal userform is displayed during the update , “Processing…”
'Uprotect WB and a few sheets
'Copies certain data sheets from Existing XLSM to New.SLXM
'Logs process to logfile.
'Displays userform now saying …process completed…
'Closes Exiting.XLSM and leaves New.xlsm open
'Hides some sheets
'Protects New.XLSM and the sheets
End Sub
I can verify that the sub completes.
The problem is after it completes. After the “completed” message is displayed, it immediately raises the following error:
“Method “InvalidateControl” of IRibbonUI failed.”
It raises this error on all controls that have a getText callback – 2 editboxes and 1 label. If I click End, the file crashes and closed. The values of those controls are stored in a worksheet. I can change the editboxes all day long and run all the other ribbon controls as well without issue. The Update sub does not touch any ribbon controls, other than being called from the Update button. Here is the code for one editbox, and similar to the other textbox.
VBA Code:
'Callback for editYears getText
Sub GetYears(control As IRibbonControl, ByRef sNumberOfYears)
sNumberOfYears = ThisWorkbook.Sheets("User Input").Range("C23")
If myRibbon Is Nothing Then
Set myRibbon = GetRibbon(sNumberOfYears)
myRibbon.InvalidateControl "editYears"
Else
sNumberOfYears = ThisWorkbook.Sheets("User Input").Range("C23")
myRibbon.InvalidateControl "editYears" 'it fails on the Else clause
End If
End Sub
“User Input” is an xlVeryHidden sheet. MyRibbon is set in the ribbon load callback
VBA Code:
'Callback for customUI.onLoad
Sub onLoad(ribbon As IRibbonUI)
Set myRibbon = ribbon
'Store pointer to IRibbonUI
ThisWorkbook.Sheets("User Input").Range("C27").Value = ObjPtr(myRibbon)
End Sub
I have looked all over for solutions, but not finding anything. Does anyone have any ideas why this is happening or can offer some troubleshooting ideas?