I use an Excel 2007 addin (xlam) and in order to change some control labels, tips, images its XML code contains an 'onLoad' procedure named "Initializare":
Most of time it works well except some cases when after VBA errors it looks that it looses the rIBB Set declaration. I mean when it tries to Invalidate controls, rIBB is not recognized and I receive the next error message: "Run-time error '91': Object variable or With block variable not set".
I can change the controls attributes only after addin closing and reopening. I tried to catch the error and reset the variable calling the 'Initializare' procedure. It is called without error but nothing (good) happens...
Here is the code where this error appears:
I tried to reinitialize the Ribbon with the next code:
'Initializare' is called without error (nothing in Immediate Window...) but control can not be changed without closing and reopening.
Is there something wrong with my way of calling 'Initializare' or is it something else?
Thanks in advance!
End Sub
Code:
Public rIBB As IRibbonUI
Sub Initializare(Ribbon As IRibbonUI)
Set rIBB = Ribbon
End Sub
I can change the controls attributes only after addin closing and reopening. I tried to catch the error and reset the variable calling the 'Initializare' procedure. It is called without error but nothing (good) happens...
Here is the code where this error appears:
Code:
Sub Invalidare()
rIBB.InvalidateControl ("checkbox_mem")
End Sub
Code:
Sub Invalidare()
On Error Resume Next
rIBB.InvalidateControl ("checkbox_mem")
If Err.Number <> 0 Then
Err.Clear
Call Initializare(Nothing)
If Err.Number <> 0 Then Debug.Print "Problem..."
rIBB.InvalidateControl ("checkbox_mem")
End If
On Error GoTo 0
Is there something wrong with my way of calling 'Initializare' or is it something else?
Thanks in advance!
End Sub