BrianExcel
Well-known Member
- Joined
- Apr 21, 2010
- Messages
- 975
I have the following code which seemed to be working fine, and now all the sudden isn't working. It's a dropdown box built into the ribbon, and when selected, calls the following code:
When I try to run the code, I get a "Run Time Error 91: Object variable or With block variable not set."
I am not sure why all the sudden it doesn't work....
Any thoughts or suggestions?
Code:
Option ExplicitDim Rib As IRibbonUI
Private mwkbNavigation As Workbook
Sub getItemCount(control As IRibbonControl, ByRef returnedVal)
Dim lCount As Long
Dim wksSheet As Worksheet
Set mwkbNavigation = ThisWorkbook
For Each wksSheet In mwkbNavigation.Worksheets
If wksSheet.Visible = xlSheetVisible Then
lCount = lCount + 1
End If
Next wksSheet
returnedVal = lCount
End Sub
Sub GetSelectedItemIndexDropDown(control As IRibbonControl, ByRef index)
index = ActiveSheet.index - 1
End Sub
Sub getItemLabel(control As IRibbonControl, index As Integer, ByRef returnedVal)
If mwkbNavigation.Worksheets(index + 1).Visible = xlSheetVisible Then
returnedVal = mwkbNavigation.Worksheets(index + 1).Name
End If
End Sub
Sub onAction(control As IRibbonControl, id As String, index As Integer)
Dim sSheetName As String
sSheetName = mwkbNavigation.Worksheets(index + 1).Name [COLOR=#ff0000][[/COLOR][COLOR=#ff0000]This is where the error occurs....][/COLOR]
mwkbNavigation.Worksheets(sSheetName).Activate
End Sub
Sub Ribbon******(ribbon As IRibbonUI)
Set Rib = ribbon
End Sub
When I try to run the code, I get a "Run Time Error 91: Object variable or With block variable not set."
I am not sure why all the sudden it doesn't work....
Any thoughts or suggestions?
Last edited: