Ribbon in a loop after reset

Paul Sansom

Board Regular
Joined
Jan 28, 2013
Messages
167
Office Version
  1. 2016
Platform
  1. Windows
Hi
After rersetting the ribbon, my workbook is in run mode, and i cannot update the workbook sheets.

Is there a way that i can identify and repair the ribbon items that appear to be casuing the loop?
I am unclear on how to determine which item(s) are causing the ribbon to stay in run mode after invalidating and resetting it?

FYI - The workbook contains many sheets. 4 custom ribbon menus each with a variatey of buttons, editboxes and textboxes.

Any help/guidance on how to find loopy code much appreciated (or please advise if more information is needed)

Cheers Paul

My refresh ribbon code is below & I believe is pretty standard
Code:
Sub RefreshRibbon(Tag As String)
    MyTag = Tag
    If Rib Is Nothing Then
        Set Rib = GetRibbon(Sheet2.Range("RibRV").Value)
        Application.StatusBar = " There was an error in the RibbonBar Initialisation - Reset in progress - please wait"
'        Rib.Invalidate
    Else
        Rib.Invalidate
    End If
    
End Sub
 

Some videos you may like

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Jeffrey Mahoney

Well-known Member
Joined
May 31, 2015
Messages
1,768
Have you tried setting breakpoints in your code and debugging it?

I've created customized ribbons, even some with menu options that change. I never had an issue with a hanging ribbon refresh.
 

Paul Sansom

Board Regular
Joined
Jan 28, 2013
Messages
167
Office Version
  1. 2016
Platform
  1. Windows
Hi Jeff
Yes i have.without too much success.
I am begining to belive the problem might be caused by the _getLabel subs for some buttons. These seem to be running continually.
I was changing the labels dependant upon consitions
I might try to remove these and just have fixed (non changing labels) and see if that solves it.
Cheers Paul
 

Jeffrey Mahoney

Well-known Member
Joined
May 31, 2015
Messages
1,768
Oh, You have events that run when you change cells that contain the labels for the buttons?

You need to do a couple things:

You need a Public boolean variable called RibbonInvalidate or something to store the status of the Invalidate process. Before Invalidate:
Application.EnableEvents = FALSE
RibbonInvalidate = TRUE

After Invalidate:
Application.EnableEvents = TRUE
RibbonInvalidate = FALSE

In each of the Ribbon process subs, just add a statement like this:
IF RibbonInvalidate = TRUE then Exit Sub

Does that make sense?
 
Last edited:

Paul Sansom

Board Regular
Joined
Jan 28, 2013
Messages
167
Office Version
  1. 2016
Platform
  1. Windows
Yes this all makes sense.
I have the events that run when a button is pressed.(_onChange) AND I change the button labels with if statements in the sub (_getLabel).
The if statements are linked to Boolean cells that change so, yes I have events that run and change the cell contents and change the labels.

I will amend the subs with the suggestions above and see. I'll post here on the outcome.
Many thanks for the persistent and patient help.

Cheers Paul
 

Jeffrey Mahoney

Well-known Member
Joined
May 31, 2015
Messages
1,768
Since I can't see all your Ribbon SUBS, I can only guess at some things. Some of your Ribbon Process Subs will need to run when Invalidate is called so they can re-label the buttons. You'll have to decide which ones those are. It may be that Disabling Events will solve the problem. Usually this is a trial and error for me.
 

Watch MrExcel Video

Forum statistics

Threads
1,109,331
Messages
5,528,052
Members
409,800
Latest member
camronmartin

This Week's Hot Topics

Top