X
xp
Hi, I have two custom toggle buttons on a ribbon and my code looks okay to
me, but obviously I've done something wrong because everytime I click either
one, I get "Object variable or with block variable not set" error; my code is
below, can someone PLEASE help me out with this?
Public gRibbonUI As IRibbonUI
Public gbPressed1 As Boolean
Public gbPressed2 As Boolean
'Callback for customUI.onLoad
Sub rxRibbonUI_onLoad(ribbon As IRibbonUI)
Set gRibbonUI = ribbon
End Sub
'Callback for rxTB1 getLabel
Sub BalAct_getLabel(control As IRibbonControl, ByRef returnedVal)
If gbPressed1 Then
returnedVal = "Activity"
ThisWorkbook.Worksheets(gcsSheetSET).Range("B14").FormulaR1C1 = "A"
Else
returnedVal = "Balance"
ThisWorkbook.Worksheets(gcsSheetSET).Range("B14").FormulaR1C1 = "B"
End If
End Sub
'Callback for rxTB1 onAction
Sub BalAct_Click(control As IRibbonControl, pressed As Boolean)
gbPressed1 = pressed
gRibbonUI.InvalidateControl ("rxTB1")
End Sub
'**********************************************************************************
'Callback for rxTB2 getLabel
Sub BudAct_getLabel(control As IRibbonControl, ByRef returnedVal)
If gbPressed2 Then
returnedVal = "Budget"
ThisWorkbook.Worksheets(gcsSheetSET).Range("B15").FormulaR1C1 = "B"
Else
returnedVal = "Actual"
ThisWorkbook.Worksheets(gcsSheetSET).Range("B14").FormulaR1C1 = "A"
End If
End Sub
'Callback for rxTB2 onAction
Sub BudAct_Click(control As IRibbonControl, pressed As Boolean)
gbPressed2 = pressed
gRibbonUI.InvalidateControl ("rxTB2")
End Sub
me, but obviously I've done something wrong because everytime I click either
one, I get "Object variable or with block variable not set" error; my code is
below, can someone PLEASE help me out with this?
Public gRibbonUI As IRibbonUI
Public gbPressed1 As Boolean
Public gbPressed2 As Boolean
'Callback for customUI.onLoad
Sub rxRibbonUI_onLoad(ribbon As IRibbonUI)
Set gRibbonUI = ribbon
End Sub
'Callback for rxTB1 getLabel
Sub BalAct_getLabel(control As IRibbonControl, ByRef returnedVal)
If gbPressed1 Then
returnedVal = "Activity"
ThisWorkbook.Worksheets(gcsSheetSET).Range("B14").FormulaR1C1 = "A"
Else
returnedVal = "Balance"
ThisWorkbook.Worksheets(gcsSheetSET).Range("B14").FormulaR1C1 = "B"
End If
End Sub
'Callback for rxTB1 onAction
Sub BalAct_Click(control As IRibbonControl, pressed As Boolean)
gbPressed1 = pressed
gRibbonUI.InvalidateControl ("rxTB1")
End Sub
'**********************************************************************************
'Callback for rxTB2 getLabel
Sub BudAct_getLabel(control As IRibbonControl, ByRef returnedVal)
If gbPressed2 Then
returnedVal = "Budget"
ThisWorkbook.Worksheets(gcsSheetSET).Range("B15").FormulaR1C1 = "B"
Else
returnedVal = "Actual"
ThisWorkbook.Worksheets(gcsSheetSET).Range("B14").FormulaR1C1 = "A"
End If
End Sub
'Callback for rxTB2 onAction
Sub BudAct_Click(control As IRibbonControl, pressed As Boolean)
gbPressed2 = pressed
gRibbonUI.InvalidateControl ("rxTB2")
End Sub